|
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 | |
|---|
| 1 | import { identity } from '../../function/identity.mjs';
|
|---|
| 2 | import { property } from '../object/property.mjs';
|
|---|
| 3 | import { matches } from '../predicate/matches.mjs';
|
|---|
| 4 | import { matchesProperty } from '../predicate/matchesProperty.mjs';
|
|---|
| 5 |
|
|---|
| 6 | function 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 |
|
|---|
| 28 | export { iteratee };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.