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.

25 lines
688 B

4 years ago
  1. var baseUniq = require('./_baseUniq');
  2. /**
  3. * Creates a duplicate-free version of an array, using
  4. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  5. * for equality comparisons, in which only the first occurrence of each element
  6. * is kept. The order of result values is determined by the order they occur
  7. * in the array.
  8. *
  9. * @static
  10. * @memberOf _
  11. * @since 0.1.0
  12. * @category Array
  13. * @param {Array} array The array to inspect.
  14. * @returns {Array} Returns the new duplicate free array.
  15. * @example
  16. *
  17. * _.uniq([2, 1, 2]);
  18. * // => [2, 1]
  19. */
  20. function uniq(array) {
  21. return (array && array.length) ? baseUniq(array) : [];
  22. }
  23. module.exports = uniq;