|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
259 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | function countBy(set, mapper) {
|
|---|
| 2 | const result = new Map();
|
|---|
| 3 | for (const value of set) {
|
|---|
| 4 | const mappedKey = mapper(value, value, set);
|
|---|
| 5 | result.set(mappedKey, (result.get(mappedKey) ?? 0) + 1);
|
|---|
| 6 | }
|
|---|
| 7 | return result;
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | export { countBy };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.