Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / array / dropWhile.js
1 var baseCallback = require('../internal/baseCallback'),
2     baseWhile = require('../internal/baseWhile');
3
4 /**
5  * Creates a slice of `array` excluding elements dropped from the beginning.
6  * Elements are dropped until `predicate` returns falsey. The predicate is
7  * bound to `thisArg` and invoked with three arguments: (value, index, array).
8  *
9  * If a property name is provided for `predicate` the created `_.property`
10  * style callback returns the property value of the given element.
11  *
12  * If a value is also provided for `thisArg` the created `_.matchesProperty`
13  * style callback returns `true` for elements that have a matching property
14  * value, else `false`.
15  *
16  * If an object is provided for `predicate` the created `_.matches` style
17  * callback returns `true` for elements that have the properties of the given
18  * object, else `false`.
19  *
20  * @static
21  * @memberOf _
22  * @category Array
23  * @param {Array} array The array to query.
24  * @param {Function|Object|string} [predicate=_.identity] The function invoked
25  *  per iteration.
26  * @param {*} [thisArg] The `this` binding of `predicate`.
27  * @returns {Array} Returns the slice of `array`.
28  * @example
29  *
30  * _.dropWhile([1, 2, 3], function(n) {
31  *   return n < 3;
32  * });
33  * // => [3]
34  *
35  * var users = [
36  *   { 'user': 'barney',  'active': false },
37  *   { 'user': 'fred',    'active': false },
38  *   { 'user': 'pebbles', 'active': true }
39  * ];
40  *
41  * // using the `_.matches` callback shorthand
42  * _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user');
43  * // => ['fred', 'pebbles']
44  *
45  * // using the `_.matchesProperty` callback shorthand
46  * _.pluck(_.dropWhile(users, 'active', false), 'user');
47  * // => ['pebbles']
48  *
49  * // using the `_.property` callback shorthand
50  * _.pluck(_.dropWhile(users, 'active'), 'user');
51  * // => ['barney', 'fred', 'pebbles']
52  */
53 function dropWhile(array, predicate, thisArg) {
54   return (array && array.length)
55     ? baseWhile(array, baseCallback(predicate, thisArg, 3), true)
56     : [];
57 }
58
59 module.exports = dropWhile;