|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
308 bytes
|
| Line | |
|---|
| 1 | function uniqBy(arr, mapper) {
|
|---|
| 2 | const map = new Map();
|
|---|
| 3 | for (let i = 0; i < arr.length; i++) {
|
|---|
| 4 | const item = arr[i];
|
|---|
| 5 | const key = mapper(item, i, arr);
|
|---|
| 6 | if (!map.has(key)) {
|
|---|
| 7 | map.set(key, item);
|
|---|
| 8 | }
|
|---|
| 9 | }
|
|---|
| 10 | return Array.from(map.values());
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | export { uniqBy };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.