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:
658 bytes
|
Rev | Line | |
---|
[d565449] | 1 | /**
|
---|
| 2 | * This function is like `baseIndexOf` except that it accepts a comparator.
|
---|
| 3 | *
|
---|
| 4 | * @private
|
---|
| 5 | * @param {Array} array The array to inspect.
|
---|
| 6 | * @param {*} value The value to search for.
|
---|
| 7 | * @param {number} fromIndex The index to search from.
|
---|
| 8 | * @param {Function} comparator The comparator invoked per element.
|
---|
| 9 | * @returns {number} Returns the index of the matched value, else `-1`.
|
---|
| 10 | */
|
---|
| 11 | function baseIndexOfWith(array, value, fromIndex, comparator) {
|
---|
| 12 | var index = fromIndex - 1,
|
---|
| 13 | length = array.length;
|
---|
| 14 |
|
---|
| 15 | while (++index < length) {
|
---|
| 16 | if (comparator(array[index], value)) {
|
---|
| 17 | return index;
|
---|
| 18 | }
|
---|
| 19 | }
|
---|
| 20 | return -1;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | export default baseIndexOfWith;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.