source: trip-planner-front/node_modules/lodash/differenceWith.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1var baseDifference = require('./_baseDifference'),
2 baseFlatten = require('./_baseFlatten'),
3 baseRest = require('./_baseRest'),
4 isArrayLikeObject = require('./isArrayLikeObject'),
5 last = require('./last');
6
7/**
8 * This method is like `_.difference` except that it accepts `comparator`
9 * which is invoked to compare elements of `array` to `values`. The order and
10 * references of result values are determined by the first array. The comparator
11 * is invoked with two arguments: (arrVal, othVal).
12 *
13 * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
14 *
15 * @static
16 * @memberOf _
17 * @since 4.0.0
18 * @category Array
19 * @param {Array} array The array to inspect.
20 * @param {...Array} [values] The values to exclude.
21 * @param {Function} [comparator] The comparator invoked per element.
22 * @returns {Array} Returns the new array of filtered values.
23 * @example
24 *
25 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
26 *
27 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
28 * // => [{ 'x': 2, 'y': 1 }]
29 */
30var differenceWith = baseRest(function(array, values) {
31 var comparator = last(values);
32 if (isArrayLikeObject(comparator)) {
33 comparator = undefined;
34 }
35 return isArrayLikeObject(array)
36 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
37 : [];
38});
39
40module.exports = differenceWith;
Note: See TracBrowser for help on using the repository browser.