diff options
author | u9g <git@u9g.dev> | 2022-03-05 19:56:46 -0500 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-03-09 10:22:20 +0330 |
commit | c8803afe3ec4f4d82dd25e378c808b4d2fb3ff6c (patch) | |
tree | 2e83f0208ecb3d15f6bdd01a97735e764e21e05f /Base/res | |
parent | b9d44eb0226d5399f60ace3fe978b22174beb1e9 (diff) | |
download | serenity-c8803afe3ec4f4d82dd25e378c808b4d2fb3ff6c.zip |
Spreadsheet: Add CommonRange#unique()
Diffstat (limited to 'Base/res')
-rw-r--r-- | Base/res/js/Spreadsheet/runtime.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Base/res/js/Spreadsheet/runtime.js b/Base/res/js/Spreadsheet/runtime.js index a0604d24f3..38977a4aee 100644 --- a/Base/res/js/Spreadsheet/runtime.js +++ b/Base/res/js/Spreadsheet/runtime.js @@ -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 { |