mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
Spreadsheet: Add CommonRange#unique()
This commit is contained in:
parent
b9d44eb022
commit
c8803afe3e
Notes:
sideshowbarker
2024-07-17 17:41:32 +09:00
Author: https://github.com/u9g
Commit: c8803afe3e
Pull-request: https://github.com/SerenityOS/serenity/pull/12882
Reviewed-by: https://github.com/alimpfard
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