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

_replaceHolders.js 785B

1234567891011121314151617181920212223242526272829
  1. /** Used as the internal argument placeholder. */
  2. var PLACEHOLDER = '__lodash_placeholder__';
  3. /**
  4. * Replaces all `placeholder` elements in `array` with an internal placeholder
  5. * and returns an array of their indexes.
  6. *
  7. * @private
  8. * @param {Array} array The array to modify.
  9. * @param {*} placeholder The placeholder to replace.
  10. * @returns {Array} Returns the new array of placeholder indexes.
  11. */
  12. function replaceHolders(array, placeholder) {
  13. var index = -1,
  14. length = array.length,
  15. resIndex = 0,
  16. result = [];
  17. while (++index < length) {
  18. var value = array[index];
  19. if (value === placeholder || value === PLACEHOLDER) {
  20. array[index] = PLACEHOLDER;
  21. result[resIndex++] = index;
  22. }
  23. }
  24. return result;
  25. }
  26. module.exports = replaceHolders;