| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const dropWhile$1 = require('../../array/dropWhile.js');
|
|---|
| 6 | const identity = require('../../function/identity.js');
|
|---|
| 7 | const toArray = require('../_internal/toArray.js');
|
|---|
| 8 | const property = require('../object/property.js');
|
|---|
| 9 | const isArrayLike = require('../predicate/isArrayLike.js');
|
|---|
| 10 | const matches = require('../predicate/matches.js');
|
|---|
| 11 | const matchesProperty = require('../predicate/matchesProperty.js');
|
|---|
| 12 |
|
|---|
| 13 | function dropWhile(arr, predicate = identity.identity) {
|
|---|
| 14 | if (!isArrayLike.isArrayLike(arr)) {
|
|---|
| 15 | return [];
|
|---|
| 16 | }
|
|---|
| 17 | return dropWhileImpl(toArray.toArray(arr), predicate);
|
|---|
| 18 | }
|
|---|
| 19 | function 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 |
|
|---|
| 42 | exports.dropWhile = dropWhile;
|
|---|