source: node_modules/es-toolkit/dist/compat/array/dropWhile.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: 1.3 KB
RevLine 
[a762898]1import { dropWhile as dropWhile$1 } from '../../array/dropWhile.mjs';
2import { identity } from '../../function/identity.mjs';
3import { toArray } from '../_internal/toArray.mjs';
4import { property } from '../object/property.mjs';
5import { isArrayLike } from '../predicate/isArrayLike.mjs';
6import { matches } from '../predicate/matches.mjs';
7import { matchesProperty } from '../predicate/matchesProperty.mjs';
8
9function dropWhile(arr, predicate = identity) {
10 if (!isArrayLike(arr)) {
11 return [];
12 }
13 return dropWhileImpl(toArray(arr), predicate);
14}
15function dropWhileImpl(arr, predicate) {
16 switch (typeof predicate) {
17 case 'function': {
18 return dropWhile$1(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
19 }
20 case 'object': {
21 if (Array.isArray(predicate) && predicate.length === 2) {
22 const key = predicate[0];
23 const value = predicate[1];
24 return dropWhile$1(arr, matchesProperty(key, value));
25 }
26 else {
27 return dropWhile$1(arr, matches(predicate));
28 }
29 }
30 case 'number':
31 case 'symbol':
32 case 'string': {
33 return dropWhile$1(arr, property(predicate));
34 }
35 }
36}
37
38export { dropWhile };
Note: See TracBrowser for help on using the repository browser.