source: imaps-frontend/node_modules/lodash-es/differenceWith.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[d565449]1import baseDifference from './_baseDifference.js';
2import baseFlatten from './_baseFlatten.js';
3import baseRest from './_baseRest.js';
4import isArrayLikeObject from './isArrayLikeObject.js';
5import last from './last.js';
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
40export default differenceWith;
Note: See TracBrowser for help on using the repository browser.