You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
749 B

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