1 | import { comparer } from '../util/comparer';
|
2 | /**
|
3 | * Determines whether an itreable includes a certain value among its entries, returning true or false as appropriate.
|
4 | *
|
5 | * @export
|
6 | * @template T The type of elements in the source sequence.
|
7 | * @param {Iterable<T>} source The source sequence to search for the item.
|
8 | * @param {T} valueToFind The value to search for.
|
9 | * @param {number} [fromIndex=0] The position in this iterable at which to begin searching for valueToFind.
|
10 | * @returns {boolean} Returns true if the value valueToFind is found within the iterable.
|
11 | */
|
12 | export function includes(source, searchElement, fromIndex = 0) {
|
13 | let fromIdx = fromIndex;
|
14 | let i = 0;
|
15 | if (Math.abs(fromIdx)) {
|
16 | fromIdx = 0;
|
17 | }
|
18 | for (const item of source) {
|
19 | if (i++ > fromIdx && comparer(item, searchElement)) {
|
20 | return true;
|
21 | }
|
22 | }
|
23 | return false;
|
24 | }
|
25 |
|
26 | //# sourceMappingURL=includes.mjs.map
|