uniq.js 688 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/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;