UNPKG

1.12 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/elementat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAI,MAAmB,EAAE,KAAa;IAC7D,IAAI,CAAC,GAAG,KAAK,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;QACzB,IAAI,CAAC,KAAK,CAAC,EAAE;YACX,OAAO,IAAI,CAAC;SACb;QACD,CAAC,EAAE,CAAC;KACL;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","file":"elementat.js","sourcesContent":["/**\n * Returns the element at a specified index in a sequence or undefined if the index is out of range.\n *\n * @export\n * @template T The type of the elements in the source sequence.\n * @param {Iterable<T>} source iterable sequence to return the element from.\n * @param {number} index The zero-based index of the element to retrieve.\n * @returns {(T | undefined)} An iterable sequence that produces the element at the specified\n * position in the source sequence, or undefined if the index is outside the bounds of the source sequence.\n */\nexport function elementAt<T>(source: Iterable<T>, index: number): T | undefined {\n let i = index;\n for (const item of source) {\n if (i === 0) {\n return item;\n }\n i--;\n }\n return undefined;\n}\n"]}
\No newline at end of file