1 | /**
|
2 | * Returns the element at a specified index in a sequence or undefined if the index is out of range.
|
3 | *
|
4 | * @export
|
5 | * @template T The type of the elements in the source sequence.
|
6 | * @param {Iterable<T>} source iterable sequence to return the element from.
|
7 | * @param {number} index The zero-based index of the element to retrieve.
|
8 | * @returns {(T | undefined)} An iterable sequence that produces the element at the specified
|
9 | * position in the source sequence, or undefined if the index is outside the bounds of the source sequence.
|
10 | */
|
11 | export function elementAt(source, index) {
|
12 | let i = index;
|
13 | for (const item of source) {
|
14 | if (i === 0) {
|
15 | return item;
|
16 | }
|
17 | i--;
|
18 | }
|
19 | return undefined;
|
20 | }
|
21 |
|
22 | //# sourceMappingURL=elementat.mjs.map
|