From 83fb13695705c34258a504bd664956b1196344d0 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 18 Aug 2025 03:26:27 +0900 Subject: [PATCH 1/6] Remove redundant error handling in ChromeObject Eliminated duplicate error response handling logic in ChromeObject and updated the version info to 0.5.3. Error messages are now handled solely by the catch block for cleaner code. --- lib/chrome.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/chrome.js b/lib/chrome.js index 1ee397d..42da405 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -440,15 +440,6 @@ var ChromeObject = function() { .send() .responseBody ; - - // response if error - if ("result" in response) { - (function(r) { - if ("subtype" in r && r.subtype == "error") { - console.warn(r.description); - } - })(response.result.result); - } } catch (e) { console.warn(e.message); response = { @@ -1507,7 +1498,7 @@ exports.startDebugInPrivate = function(url, proxy, profileName, debuggingPort, i exports.publisherName = publisherName; -exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.5.2"; +exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.5.3"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require; From 717b141cb7151d5a004ed286b34ede520aefc528 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 18 Aug 2025 04:16:52 +0900 Subject: [PATCH 2/6] Add clusteredCellsDensity function to extramath.js Introduces clusteredCellsDensity to evaluate density of selected cells within a grid. Updates module version to 1.0.0 and exports the new function for external use. --- lib/extramath.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/extramath.js b/lib/extramath.js index 8076ff7..db416fd 100644 --- a/lib/extramath.js +++ b/lib/extramath.js @@ -70,13 +70,40 @@ function cartesianProduct(arr) { }, [[]]) } +function clusteredCellsDensity(numbers, size, minDensity) { + if (!numbers || !numbers.length) return false; + if (typeof minDensity === 'undefined') minDensity = 0.6; + if (typeof size !== 'number' || size <= 0) size = 4; // default grid size = 4 + + // 1. Convert cell number → (x,y) coordinates + var coords = numbers.map(function (n) { + return { x: n % size, y: Math.floor(n / size) }; + }); + + var xs = coords.map(function (c) { return c.x; }); + var ys = coords.map(function (c) { return c.y; }); + + // 2. Compute bounding box of selected cells + var minX = Math.min.apply(Math, xs), maxX = Math.max.apply(Math, xs); + var minY = Math.min.apply(Math, ys), maxY = Math.max.apply(Math, ys); + + // 3. Compute area and density + var w = maxX - minX + 1; + var h = maxY - minY + 1; + var boxArea = w * h; + + var density = coords.length / boxArea; + return density >= minDensity; +} + exports.DTM = DTM; exports.arrayCos = arrayCos; exports.measureSimilarity = measureSimilarity; exports.export_measureSimilarity = export_measureSimilarity; exports.cartesianProduct = cartesianProduct; +exports.clusteredCellsDensity = clusteredCellsDensity; -exports.VERSIONINFO = "ExtraMath module (extramath.js) version 0.0.5"; +exports.VERSIONINFO = "ExtraMath module (extramath.js) version 1.0.0"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require; From ab869556c4fbad8b29aa01245d05d78504be771d Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 18 Aug 2025 07:20:01 +0900 Subject: [PATCH 3/6] Add tileStartPos function and update version Introduced tileStartPos to calculate tile coordinates based on index, size, and columns. Updated VERSIONINFO to 1.0.1 and exported the new function. --- lib/extramath.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/extramath.js b/lib/extramath.js index db416fd..0b1556b 100644 --- a/lib/extramath.js +++ b/lib/extramath.js @@ -56,7 +56,7 @@ function measureSimilarity(s1, s2) { } function export_measureSimilarity() { - return "var ExtraMath=function(){};ExtraMath.DTM=function(){this.data=[],this.terms=[],this.add=function(t){for(var r=t.trim().split(/\s+/),a=0;athis.terms.indexOf(r[a])&&this.terms.push(r[a]);this.data.push(r)},this.toArray=function(){for(var t=[],r=0;rthis.data[r].indexOf(this.terms[s])?0:1);t.push(a)}return t}},ExtraMath.arrayCos=function(t,r){var a=0,s=0,h=0;for(i=0;ithis.terms.indexOf(r[a])&&this.terms.push(r[a]);this.data.push(r)},this.toArray=function(){for(var t=[],r=0;rthis.data[r].indexOf(this.terms[s])?0:1);t.push(a)}return t}},ExtraMath.arrayCos=function(t,r){var a=0,s=0,h=0;for(i=0;i= minDensity; } +function tileStartPos(index, size, cols) { + if (typeof size !== 'number') size = 130; + if (typeof cols !== 'number') cols = 4; + + var i = index - 1; // convert 1-based -> 0-based + var col = i % cols; + var row = Math.floor(i / cols); + return { x: col * size, y: row * size }; +} + exports.DTM = DTM; exports.arrayCos = arrayCos; exports.measureSimilarity = measureSimilarity; exports.export_measureSimilarity = export_measureSimilarity; exports.cartesianProduct = cartesianProduct; exports.clusteredCellsDensity = clusteredCellsDensity; +exports.tileStartPos = tileStartPos; -exports.VERSIONINFO = "ExtraMath module (extramath.js) version 1.0.0"; +exports.VERSIONINFO = "ExtraMath module (extramath.js) version 1.0.1"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require; From 83b022bf6fbe73f472f0ed5829c7a47c8d1d2590 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 20 Aug 2025 17:10:58 +0900 Subject: [PATCH 4/6] Refactor grid functions and update exports in extramath.js Improved clusteredCellsDensity to validate cell indices and refactored coordinate calculation to be 1-based. Replaced tileStartPos with estimateTileStartPosition for more flexible tile positioning, updated exports accordingly, and bumped VERSIONINFO to 1.0.3. --- lib/extramath.js | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/lib/extramath.js b/lib/extramath.js index 0b1556b..2a7254f 100644 --- a/lib/extramath.js +++ b/lib/extramath.js @@ -72,13 +72,22 @@ function cartesianProduct(arr) { function clusteredCellsDensity(numbers, size, minDensity) { if (!numbers || !numbers.length) return false; - if (typeof minDensity === 'undefined') minDensity = 0.6; if (typeof size !== 'number' || size <= 0) size = 4; // default grid size = 4 + if (typeof minDensity === 'undefined') minDensity = 0.6; - // 1. Convert cell number → (x,y) coordinates - var coords = numbers.map(function (n) { - return { x: n % size, y: Math.floor(n / size) }; - }); + var maxIndex = size * size; // because it's 1-based (1..size*size) + + // 1. Convert cell number → (x,y) coordinates with 1-based check + var coords = []; + for (var i = 0; i < numbers.length; i++) { + var n = numbers[i]; + // must be within 1..maxIndex + if (typeof n !== 'number' || n < 1 || n > maxIndex) { + return false; // invalid index -> immediately return false + } + var idx = n - 1; // shift to 0-based + coords.push({ x: idx % size, y: Math.floor(idx / size) }); + } var xs = coords.map(function (c) { return c.x; }); var ys = coords.map(function (c) { return c.y; }); @@ -96,14 +105,17 @@ function clusteredCellsDensity(numbers, size, minDensity) { return density >= minDensity; } -function tileStartPos(index, size, cols) { - if (typeof size !== 'number') size = 130; - if (typeof cols !== 'number') cols = 4; +function estimateTileStartPosition(index, tiles, spreadSize, gap) { + var tileSize = (spreadSize - gap * (tiles - 1)) / tiles; - var i = index - 1; // convert 1-based -> 0-based - var col = i % cols; - var row = Math.floor(i / cols); - return { x: col * size, y: row * size }; + var i = index - 1; + var col = i % tiles; + var row = Math.floor(i / tiles); + + return { + x: col * (tileSize + gap), + y: row * (tileSize + gap) + }; } exports.DTM = DTM; @@ -112,9 +124,9 @@ exports.measureSimilarity = measureSimilarity; exports.export_measureSimilarity = export_measureSimilarity; exports.cartesianProduct = cartesianProduct; exports.clusteredCellsDensity = clusteredCellsDensity; -exports.tileStartPos = tileStartPos; +exports.estimateTileStartPosition = estimateTileStartPosition; -exports.VERSIONINFO = "ExtraMath module (extramath.js) version 1.0.1"; +exports.VERSIONINFO = "ExtraMath module (extramath.js) version 1.0.3"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require; From 1dd02f7a7511de2d5ba0684da4ba1c7d422098fb Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 20 Aug 2025 17:25:51 +0900 Subject: [PATCH 5/6] Update lib/extramath.js Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- lib/extramath.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/extramath.js b/lib/extramath.js index 2a7254f..594f85d 100644 --- a/lib/extramath.js +++ b/lib/extramath.js @@ -73,7 +73,7 @@ function cartesianProduct(arr) { function clusteredCellsDensity(numbers, size, minDensity) { if (!numbers || !numbers.length) return false; if (typeof size !== 'number' || size <= 0) size = 4; // default grid size = 4 - if (typeof minDensity === 'undefined') minDensity = 0.6; + if (typeof minDensity !== 'number' || isNaN(minDensity)) minDensity = 0.6; var maxIndex = size * size; // because it's 1-based (1..size*size) From 8ff12c98837720255621dcd2cb3245cf65ff6cc6 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 20 Aug 2025 17:29:44 +0900 Subject: [PATCH 6/6] Update lib/extramath.js Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com> --- lib/extramath.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/extramath.js b/lib/extramath.js index 594f85d..b4d9bd4 100644 --- a/lib/extramath.js +++ b/lib/extramath.js @@ -105,16 +105,25 @@ function clusteredCellsDensity(numbers, size, minDensity) { return density >= minDensity; } -function estimateTileStartPosition(index, tiles, spreadSize, gap) { +function estimateTileStartPosition(index, tiles, spreadSize, gap) { + if (typeof tiles !== 'number' || tiles <= 0) return null; + if (typeof spreadSize !== 'number' || !isFinite(spreadSize)) return null; + if (typeof gap !== 'number' || !isFinite(gap) || gap < 0) gap = 0; + if (typeof index !== 'number' || !isFinite(index) || index % 1 !== 0 || index < 1) return null; + + var totalSlots = tiles * tiles; + if (index > totalSlots) return null; + var tileSize = (spreadSize - gap * (tiles - 1)) / tiles; + if (!isFinite(tileSize)) return null; var i = index - 1; var col = i % tiles; var row = Math.floor(i / tiles); - - return { - x: col * (tileSize + gap), - y: row * (tileSize + gap) + + return { + x: Math.max(0, col) * (tileSize + gap), + y: Math.max(0, row) * (tileSize + gap) }; }