source: node_modules/es-toolkit/dist/array/countBy.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 263 bytes
Line 
1function countBy(arr, mapper) {
2 const result = {};
3 for (let i = 0; i < arr.length; i++) {
4 const item = arr[i];
5 const key = mapper(item, i, arr);
6 result[key] = (result[key] ?? 0) + 1;
7 }
8 return result;
9}
10
11export { countBy };
Note: See TracBrowser for help on using the repository browser.