summaryrefslogtreecommitdiff
path: root/Base/res
diff options
context:
space:
mode:
authoru9g <git@u9g.dev>2022-03-02 18:30:14 -0500
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-03-04 04:29:20 +0330
commit93115ee0449dff2601fb0f005789fcad7ee91709 (patch)
treec2075b0746e35fff891868a4b32b3dce3bf7d233 /Base/res
parent6302ca00431b96d22dbc68a2fa60d0e569775b13 (diff)
downloadserenity-93115ee0449dff2601fb0f005789fcad7ee91709.zip
Spreadsheet: Add Range(s).toArray()
Diffstat (limited to 'Base/res')
-rw-r--r--Base/res/js/Spreadsheet/runtime.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/Base/res/js/Spreadsheet/runtime.js b/Base/res/js/Spreadsheet/runtime.js
index 616988a1dc..58af22548b 100644
--- a/Base/res/js/Spreadsheet/runtime.js
+++ b/Base/res/js/Spreadsheet/runtime.js
@@ -171,6 +171,12 @@ class Ranges {
}
}
+ toArray() {
+ const cells = [];
+ this.forEach(val => cells.push(val));
+ return cells;
+ }
+
toString() {
return `Ranges.from(${this.ranges.map(r => r.toString()).join(", ")})`;
}
@@ -263,6 +269,12 @@ class Range {
}
}
+ toArray() {
+ const cells = [];
+ this.forEach(val => cells.push(val));
+ return cells;
+ }
+
toString() {
const endingRow = this.endingRow ?? "";
return `R\`${this.startingColumnName}${this.startingRow}:${this.endingColumnName}${endingRow}:${this.columnStep}:${this.rowStep}\``;
@@ -340,12 +352,8 @@ function numericResolve(cells) {
}
function resolve(cells) {
- let values = [];
- if (cells instanceof Range || cells instanceof Ranges)
- cells.forEach(cell => values.push(cell.value()));
- else values = cells;
-
- return values;
+ const isRange = cells instanceof Range || cells instanceof Ranges;
+ return isRange ? cells.toArray().map(cell => cell.value()) : cells;
}
// Statistics