mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:18:13 +00:00
Spreadsheet: Add CommonRange#unique()
This commit is contained in:
parent
b9d44eb022
commit
c8803afe3e
2 changed files with 28 additions and 0 deletions
|
@ -197,6 +197,19 @@ class CommonRange {
|
|||
});
|
||||
return new SplitRange(cells);
|
||||
}
|
||||
|
||||
unique() {
|
||||
const cells = [];
|
||||
const values = new Set();
|
||||
this.forEach(cell => {
|
||||
const value = cell.value();
|
||||
if (!values.has(value)) {
|
||||
values.add(value);
|
||||
cells.push(cell);
|
||||
}
|
||||
});
|
||||
return new SplitRange(cells);
|
||||
}
|
||||
}
|
||||
|
||||
class SplitRange extends CommonRange {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue