1 var baseIteratee = require('./_baseIteratee'),
2 basePullAt = require('./_basePullAt');
5 * Removes all elements from `array` that `predicate` returns truthy for
6 * and returns an array of the removed elements. The predicate is invoked with
7 * three arguments: (value, index, array).
9 * **Note:** Unlike `_.filter`, this method mutates `array`.
14 * @param {Array} array The array to modify.
15 * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration.
16 * @returns {Array} Returns the new array of removed elements.
19 * var array = [1, 2, 3, 4];
20 * var evens = _.remove(array, function(n) {
30 function remove(array, predicate) {
32 if (!(array && array.length)) {
37 length = array.length;
39 predicate = baseIteratee(predicate, 3);
40 while (++index < length) {
41 var value = array[index];
42 if (predicate(value, index, array)) {
47 basePullAt(array, indexes);
51 module.exports = remove;