main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
783 bytes
|
Rev | Line | |
---|
[d565449] | 1 | /** Used as the internal argument placeholder. */
|
---|
| 2 | var PLACEHOLDER = '__lodash_placeholder__';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Replaces all `placeholder` elements in `array` with an internal placeholder
|
---|
| 6 | * and returns an array of their indexes.
|
---|
| 7 | *
|
---|
| 8 | * @private
|
---|
| 9 | * @param {Array} array The array to modify.
|
---|
| 10 | * @param {*} placeholder The placeholder to replace.
|
---|
| 11 | * @returns {Array} Returns the new array of placeholder indexes.
|
---|
| 12 | */
|
---|
| 13 | function replaceHolders(array, placeholder) {
|
---|
| 14 | var index = -1,
|
---|
| 15 | length = array.length,
|
---|
| 16 | resIndex = 0,
|
---|
| 17 | result = [];
|
---|
| 18 |
|
---|
| 19 | while (++index < length) {
|
---|
| 20 | var value = array[index];
|
---|
| 21 | if (value === placeholder || value === PLACEHOLDER) {
|
---|
| 22 | array[index] = PLACEHOLDER;
|
---|
| 23 | result[resIndex++] = index;
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 | return result;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | export default replaceHolders;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.