source: node_modules/es-toolkit/dist/compat/util/iteratee.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: 755 bytes
Line 
1import { identity } from '../../function/identity.mjs';
2import { property } from '../object/property.mjs';
3import { matches } from '../predicate/matches.mjs';
4import { matchesProperty } from '../predicate/matchesProperty.mjs';
5
6function iteratee(value) {
7 if (value == null) {
8 return identity;
9 }
10 switch (typeof value) {
11 case 'function': {
12 return value;
13 }
14 case 'object': {
15 if (Array.isArray(value) && value.length === 2) {
16 return matchesProperty(value[0], value[1]);
17 }
18 return matches(value);
19 }
20 case 'string':
21 case 'symbol':
22 case 'number': {
23 return property(value);
24 }
25 }
26}
27
28export { iteratee };
Note: See TracBrowser for help on using the repository browser.