Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

29 rindas
785 B

pirms 3 gadiem
  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;