source: node_modules/es-toolkit/dist/compat/array/takeWhile.mjs@ ba17441

Last change on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 573 bytes
Line 
1import { toArray } from '../_internal/toArray.mjs';
2import { identity } from '../function/identity.mjs';
3import { negate } from '../function/negate.mjs';
4import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
5import { iteratee } from '../util/iteratee.mjs';
6
7function 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
16export { takeWhile };
Note: See TracBrowser for help on using the repository browser.