1 var baseIteratee = require('./internal/baseIteratee'),
2 baseWhile = require('./internal/baseWhile');
5 * Creates a slice of `array` excluding elements dropped from the end.
6 * Elements are dropped until `predicate` returns falsey. The predicate is
7 * invoked with three arguments: (value, index, array).
12 * @param {Array} array The array to query.
13 * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration.
14 * @returns {Array} Returns the slice of `array`.
18 * { 'user': 'barney', 'active': true },
19 * { 'user': 'fred', 'active': false },
20 * { 'user': 'pebbles', 'active': false }
23 * _.dropRightWhile(users, function(o) { return !o.active; });
24 * // => objects for ['barney']
26 * // using the `_.matches` iteratee shorthand
27 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
28 * // => objects for ['barney', 'fred']
30 * // using the `_.matchesProperty` iteratee shorthand
31 * _.dropRightWhile(users, ['active', false]);
32 * // => objects for ['barney']
34 * // using the `_.property` iteratee shorthand
35 * _.dropRightWhile(users, 'active');
36 * // => objects for ['barney', 'fred', 'pebbles']
38 function dropRightWhile(array, predicate) {
39 return (array && array.length)
40 ? baseWhile(array, baseIteratee(predicate, 3), true, true)
44 module.exports = dropRightWhile;