source: node_modules/es-toolkit/dist/compat/array/dropWhile.js

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.5 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const dropWhile$1 = require('../../array/dropWhile.js');
6const identity = require('../../function/identity.js');
7const toArray = require('../_internal/toArray.js');
8const property = require('../object/property.js');
9const isArrayLike = require('../predicate/isArrayLike.js');
10const matches = require('../predicate/matches.js');
11const matchesProperty = require('../predicate/matchesProperty.js');
12
13function dropWhile(arr, predicate = identity.identity) {
14 if (!isArrayLike.isArrayLike(arr)) {
15 return [];
16 }
17 return dropWhileImpl(toArray.toArray(arr), predicate);
18}
19function dropWhileImpl(arr, predicate) {
20 switch (typeof predicate) {
21 case 'function': {
22 return dropWhile$1.dropWhile(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
23 }
24 case 'object': {
25 if (Array.isArray(predicate) && predicate.length === 2) {
26 const key = predicate[0];
27 const value = predicate[1];
28 return dropWhile$1.dropWhile(arr, matchesProperty.matchesProperty(key, value));
29 }
30 else {
31 return dropWhile$1.dropWhile(arr, matches.matches(predicate));
32 }
33 }
34 case 'number':
35 case 'symbol':
36 case 'string': {
37 return dropWhile$1.dropWhile(arr, property.property(predicate));
38 }
39 }
40}
41
42exports.dropWhile = dropWhile;
Note: See TracBrowser for help on using the repository browser.