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