source: node_modules/es-toolkit/dist/compat/array/takeWhile.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: 722 bytes
RevLine 
[a762898]1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const toArray = require('../_internal/toArray.js');
6const identity = require('../function/identity.js');
7const negate = require('../function/negate.js');
8const isArrayLikeObject = require('../predicate/isArrayLikeObject.js');
9const iteratee = require('../util/iteratee.js');
10
11function takeWhile(array, predicate) {
12 if (!isArrayLikeObject.isArrayLikeObject(array)) {
13 return [];
14 }
15 const _array = toArray.toArray(array);
16 const index = _array.findIndex(negate.negate(iteratee.iteratee(predicate ?? identity.identity)));
17 return index === -1 ? _array : _array.slice(0, index);
18}
19
20exports.takeWhile = takeWhile;
Note: See TracBrowser for help on using the repository browser.