uniq.js 614 B

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