sortedUniq.js 513 B

12345678910111213141516171819202122232425
  1. var baseSortedUniq = require('./_baseSortedUniq');
  2. /**
  3. * This method is like `_.uniq` except that it's designed and optimized
  4. * for sorted arrays.
  5. *
  6. * @static
  7. * @memberOf _
  8. * @since 4.0.0
  9. * @category Array
  10. * @param {Array} array The array to inspect.
  11. * @returns {Array} Returns the new duplicate free array.
  12. * @example
  13. *
  14. * _.sortedUniq([1, 1, 2]);
  15. * // => [1, 2]
  16. */
  17. function sortedUniq(array) {
  18. return (array && array.length)
  19. ? baseSortedUniq(array)
  20. : [];
  21. }
  22. module.exports = sortedUniq;