UNPKG

1.03 kBJavaScriptView Raw
1import basePullAll from './_basePullAll.js';
2
3/**
4 * This method is like `_.pullAll` except that it accepts `comparator` which
5 * is invoked to compare elements of `array` to `values`. The comparator is
6 * invoked with two arguments: (arrVal, othVal).
7 *
8 * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
9 *
10 * @static
11 * @memberOf _
12 * @since 4.6.0
13 * @category Array
14 * @param {Array} array The array to modify.
15 * @param {Array} values The values to remove.
16 * @param {Function} [comparator] The comparator invoked per element.
17 * @returns {Array} Returns `array`.
18 * @example
19 *
20 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
21 *
22 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
23 * console.log(array);
24 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
25 */
26function pullAllWith(array, values, comparator) {
27 return (array && array.length && values && values.length)
28 ? basePullAll(array, values, undefined, comparator)
29 : array;
30}
31
32export default pullAllWith;