source: imaps-frontend/node_modules/lodash-es/unionWith.js

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

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.2 KB
Line 
1import baseFlatten from './_baseFlatten.js';
2import baseRest from './_baseRest.js';
3import baseUniq from './_baseUniq.js';
4import isArrayLikeObject from './isArrayLikeObject.js';
5import last from './last.js';
6
7/**
8 * This method is like `_.union` except that it accepts `comparator` which
9 * is invoked to compare elements of `arrays`. Result values are chosen from
10 * the first array in which the value occurs. The comparator is invoked
11 * with two arguments: (arrVal, othVal).
12 *
13 * @static
14 * @memberOf _
15 * @since 4.0.0
16 * @category Array
17 * @param {...Array} [arrays] The arrays to inspect.
18 * @param {Function} [comparator] The comparator invoked per element.
19 * @returns {Array} Returns the new array of combined values.
20 * @example
21 *
22 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
23 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
24 *
25 * _.unionWith(objects, others, _.isEqual);
26 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
27 */
28var unionWith = baseRest(function(arrays) {
29 var comparator = last(arrays);
30 comparator = typeof comparator == 'function' ? comparator : undefined;
31 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
32});
33
34export default unionWith;
Note: See TracBrowser for help on using the repository browser.