UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

25 lines (24 loc) 848 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const CONSTANTS_1 = require("./CONSTANTS"); /** * Replaces all `placeholder` elements in `array` with an internal placeholder * and returns an array of their indexes. * * @private * @param {Array} array The array to modify. * @param {*} placeholder The placeholder to replace. * @returns {Array} Returns the new array of placeholder indexes. */ function replaceHolders(array, placeholder) { var index = -1, length = array.length, resIndex = 0, result = []; while (++index < length) { var value = array[index]; if (value === placeholder || value === CONSTANTS_1.PLACEHOLDER) { array[index] = CONSTANTS_1.PLACEHOLDER; result[resIndex++] = index; } } return result; } exports.default = replaceHolders;