Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

_baseSortedUniq.js 758B

123456789101112131415161718192021222324252627282930
  1. var eq = require('./eq');
  2. /**
  3. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  4. * support for iteratee shorthands.
  5. *
  6. * @private
  7. * @param {Array} array The array to inspect.
  8. * @param {Function} [iteratee] The iteratee invoked per element.
  9. * @returns {Array} Returns the new duplicate free array.
  10. */
  11. function baseSortedUniq(array, iteratee) {
  12. var index = -1,
  13. length = array.length,
  14. resIndex = 0,
  15. result = [];
  16. while (++index < length) {
  17. var value = array[index],
  18. computed = iteratee ? iteratee(value) : value;
  19. if (!index || !eq(computed, seen)) {
  20. var seen = computed;
  21. result[resIndex++] = value === 0 ? 0 : value;
  22. }
  23. }
  24. return result;
  25. }
  26. module.exports = baseSortedUniq;