mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
Spreadsheet: Add Range(s).at(ix)
This commit is contained in:
parent
629eed3a4c
commit
d047f26a74
2 changed files with 37 additions and 0 deletions
|
@ -147,6 +147,18 @@ class Ranges {
|
|||
}
|
||||
}
|
||||
|
||||
at(wantedIx) {
|
||||
let ix = 0;
|
||||
let found = null;
|
||||
this.forEach(cell => {
|
||||
if (ix++ === wantedIx) {
|
||||
found = cell;
|
||||
return Break;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
union(other, direction = "right") {
|
||||
if (direction === "left") {
|
||||
if (other instanceof Ranges) return Ranges.from(...other.ranges, ...this.ranges);
|
||||
|
@ -213,6 +225,18 @@ class Range {
|
|||
}
|
||||
}
|
||||
|
||||
at(wantedIx) {
|
||||
let ix = 0;
|
||||
let found = null;
|
||||
this.forEach(cell => {
|
||||
if (ix++ === wantedIx) {
|
||||
found = cell;
|
||||
return Break;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
union(other) {
|
||||
if (other instanceof Ranges) return other.union(this, "left");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue