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