UNPKG

747 BJavaScriptView Raw
1import baseFlatten from './_baseFlatten.js';
2import baseRest from './_baseRest.js';
3import baseUniq from './_baseUniq.js';
4import isArrayLikeObject from './isArrayLikeObject.js';
5
6/**
7 * Creates an array of unique values, in order, from all given arrays using
8 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
9 * for equality comparisons.
10 *
11 * @static
12 * @memberOf _
13 * @since 0.1.0
14 * @category Array
15 * @param {...Array} [arrays] The arrays to inspect.
16 * @returns {Array} Returns the new array of combined values.
17 * @example
18 *
19 * _.union([2], [1, 2]);
20 * // => [2, 1]
21 */
22var union = baseRest(function(arrays) {
23 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
24});
25
26export default union;