|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
573 bytes
|
| Line | |
|---|
| 1 | import { toArray } from '../_internal/toArray.mjs';
|
|---|
| 2 | import { identity } from '../function/identity.mjs';
|
|---|
| 3 | import { negate } from '../function/negate.mjs';
|
|---|
| 4 | import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
|
|---|
| 5 | import { iteratee } from '../util/iteratee.mjs';
|
|---|
| 6 |
|
|---|
| 7 | function takeWhile(array, predicate) {
|
|---|
| 8 | if (!isArrayLikeObject(array)) {
|
|---|
| 9 | return [];
|
|---|
| 10 | }
|
|---|
| 11 | const _array = toArray(array);
|
|---|
| 12 | const index = _array.findIndex(negate(iteratee(predicate ?? identity)));
|
|---|
| 13 | return index === -1 ? _array : _array.slice(0, index);
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | export { takeWhile };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.