mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Bump to v4.1.0.
This commit is contained in:
31
_replaceHolders.js
Normal file
31
_replaceHolders.js
Normal file
@@ -0,0 +1,31 @@
|
||||
define([], function() {
|
||||
|
||||
/** Used as the internal argument placeholder. */
|
||||
var 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) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
resIndex = -1,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === placeholder) {
|
||||
array[index] = PLACEHOLDER;
|
||||
result[++resIndex] = index;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return replaceHolders;
|
||||
});
|
||||
Reference in New Issue
Block a user