|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
543 bytes
|
| Line | |
|---|
| 1 | import { groupBy as groupBy$1 } from '../../array/groupBy.mjs';
|
|---|
| 2 | import { identity } from '../../function/identity.mjs';
|
|---|
| 3 | import { isArrayLike } from '../predicate/isArrayLike.mjs';
|
|---|
| 4 | import { iteratee } from '../util/iteratee.mjs';
|
|---|
| 5 |
|
|---|
| 6 | function groupBy(source, _getKeyFromItem) {
|
|---|
| 7 | if (source == null) {
|
|---|
| 8 | return {};
|
|---|
| 9 | }
|
|---|
| 10 | const items = isArrayLike(source) ? Array.from(source) : Object.values(source);
|
|---|
| 11 | const getKeyFromItem = iteratee(_getKeyFromItem ?? identity);
|
|---|
| 12 | return groupBy$1(items, getKeyFromItem);
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | export { groupBy };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.