react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / array / dropRightWhile.js
80742 viewsvar baseCallback = require('../internal/baseCallback'),1baseWhile = require('../internal/baseWhile');23/**4* Creates a slice of `array` excluding elements dropped from the end.5* Elements are dropped until `predicate` returns falsey. The predicate is6* bound to `thisArg` and invoked with three arguments: (value, index, array).7*8* If a property name is provided for `predicate` the created `_.property`9* style callback returns the property value of the given element.10*11* If a value is also provided for `thisArg` the created `_.matchesProperty`12* style callback returns `true` for elements that have a matching property13* value, else `false`.14*15* If an object is provided for `predicate` the created `_.matches` style16* callback returns `true` for elements that match the properties of the given17* object, else `false`.18*19* @static20* @memberOf _21* @category Array22* @param {Array} array The array to query.23* @param {Function|Object|string} [predicate=_.identity] The function invoked24* per iteration.25* @param {*} [thisArg] The `this` binding of `predicate`.26* @returns {Array} Returns the slice of `array`.27* @example28*29* _.dropRightWhile([1, 2, 3], function(n) {30* return n > 1;31* });32* // => [1]33*34* var users = [35* { 'user': 'barney', 'active': true },36* { 'user': 'fred', 'active': false },37* { 'user': 'pebbles', 'active': false }38* ];39*40* // using the `_.matches` callback shorthand41* _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');42* // => ['barney', 'fred']43*44* // using the `_.matchesProperty` callback shorthand45* _.pluck(_.dropRightWhile(users, 'active', false), 'user');46* // => ['barney']47*48* // using the `_.property` callback shorthand49* _.pluck(_.dropRightWhile(users, 'active'), 'user');50* // => ['barney', 'fred', 'pebbles']51*/52function dropRightWhile(array, predicate, thisArg) {53return (array && array.length)54? baseWhile(array, baseCallback(predicate, thisArg, 3), true, true)55: [];56}5758module.exports = dropRightWhile;596061