Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | var basePullAll = require('./_basePullAll');
|
---|
| 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 | */
|
---|
| 26 | function pullAllWith(array, values, comparator) {
|
---|
| 27 | return (array && array.length && values && values.length)
|
---|
| 28 | ? basePullAll(array, values, undefined, comparator)
|
---|
| 29 | : array;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | module.exports = pullAllWith;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.