* Removes all elements from `array` that `predicate` returns truthy for * and returns an array of the removed elements. The predicate is invoked * with three arguments: (value, index, array). * * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` * to pul
(array, predicate)
| 15478 | * // => [2, 4] |
| 15479 | */ |
| 15480 | function remove(array, predicate) { |
| 15481 | var result = []; |
| 15482 | if (!(array && array.length)) { |
| 15483 | return result; |
| 15484 | } |
| 15485 | var index = -1, |
| 15486 | indexes = [], |
| 15487 | length = array.length; |
| 15488 | |
| 15489 | predicate = getIteratee(predicate, 3); |
| 15490 | while (++index < length) { |
| 15491 | var value = array[index]; |
| 15492 | if (predicate(value, index, array)) { |
| 15493 | result.push(value); |
| 15494 | indexes.push(index); |
| 15495 | } |
| 15496 | } |
| 15497 | basePullAt(array, indexes); |
| 15498 | return result; |
| 15499 | } |
| 15500 | |
| 15501 | /** |
| 15502 | * Reverses `array` so that the first element becomes the last, the second |
no test coverage detected