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
7 * with three arguments: (value, index, array).
9 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
10 * to pull elements from an array by value.
16 * @param {Array} array The array to modify.
17 * @param {Function} [predicate=_.identity] The function invoked per iteration.
18 * @returns {Array} Returns the new array of removed elements.
21 * var array = [1, 2, 3, 4];
22 * var evens = _.remove(array, function(n) {
32 function remove(array, predicate) {
34 if (!(array && array.length)) {
39 length = array.length;
41 predicate = baseIteratee(predicate, 3);
42 while (++index < length) {
43 var value = array[index];
44 if (predicate(value, index, array)) {
49 basePullAt(array, indexes);
53 module.exports = remove;