mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
29
.internal/replaceHolders.js
Normal file
29
.internal/replaceHolders.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/** Used as the internal argument placeholder. */
|
||||
const PLACEHOLDER = '__lodash_placeholder__';
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
let index = -1;
|
||||
const length = array.length;
|
||||
let resIndex = 0;
|
||||
const result = [];
|
||||
|
||||
while (++index < length) {
|
||||
const value = array[index];
|
||||
if (value === placeholder || value === PLACEHOLDER) {
|
||||
array[index] = PLACEHOLDER;
|
||||
result[resIndex++] = index;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export default replaceHolders;
|
||||
Reference in New Issue
Block a user