mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 23:37:49 +00:00
Bump to v3.6.0.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import baseCallback from '../internal/baseCallback';
|
||||
import baseSlice from '../internal/baseSlice';
|
||||
import baseWhile from '../internal/baseWhile';
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` with elements taken from the beginning. Elements
|
||||
* are taken until `predicate` returns falsey. The predicate is bound to
|
||||
* `thisArg` and invoked with three arguments; (value, index, array).
|
||||
* `thisArg` and invoked with three arguments: (value, index, array).
|
||||
*
|
||||
* If a property name is provided for `predicate` the created `_.property`
|
||||
* style callback returns the property value of the given element.
|
||||
@@ -51,14 +51,9 @@ import baseSlice from '../internal/baseSlice';
|
||||
* // => []
|
||||
*/
|
||||
function takeWhile(array, predicate, thisArg) {
|
||||
var length = array ? array.length : 0;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
var index = -1;
|
||||
predicate = baseCallback(predicate, thisArg, 3);
|
||||
while (++index < length && predicate(array[index], index, array)) {}
|
||||
return baseSlice(array, 0, index);
|
||||
return (array && array.length)
|
||||
? baseWhile(array, baseCallback(predicate, thisArg, 3))
|
||||
: [];
|
||||
}
|
||||
|
||||
export default takeWhile;
|
||||
|
||||
Reference in New Issue
Block a user