|
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
|
| Rev | Line | |
|---|
| [a762898] | 1 | import { dropWhile as dropWhile$1 } from '../../array/dropWhile.mjs';
|
|---|
| 2 | import { identity } from '../../function/identity.mjs';
|
|---|
| 3 | import { toArray } from '../_internal/toArray.mjs';
|
|---|
| 4 | import { property } from '../object/property.mjs';
|
|---|
| 5 | import { isArrayLike } from '../predicate/isArrayLike.mjs';
|
|---|
| 6 | import { matches } from '../predicate/matches.mjs';
|
|---|
| 7 | import { matchesProperty } from '../predicate/matchesProperty.mjs';
|
|---|
| 8 |
|
|---|
| 9 | function dropWhile(arr, predicate = identity) {
|
|---|
| 10 | if (!isArrayLike(arr)) {
|
|---|
| 11 | return [];
|
|---|
| 12 | }
|
|---|
| 13 | return dropWhileImpl(toArray(arr), predicate);
|
|---|
| 14 | }
|
|---|
| 15 | function 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 |
|
|---|
| 38 | export { dropWhile };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.