forked from lodash/lodash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdropWhile.js
30 lines (28 loc) · 870 Bytes
/
dropWhile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import baseWhile from './.internal/baseWhile.js';
/**
* Creates a slice of `array` excluding elements dropped from the beginning.
* Elements are dropped until `predicate` returns falsey. The predicate is
* invoked with three arguments: (value, index, array).
*
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {Function} predicate The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
* const users = [
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': true },
* { 'user': 'pebbles', 'active': false }
* ];
*
* dropWhile(users, ({ active }) => active);
* // => objects for ['pebbles']
*/
function dropWhile(array, predicate) {
return (array && array.length)
? baseWhile(array, predicate, true)
: [];
}
export default dropWhile;