UNPKG

1.42 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/findindex.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAI,MAAmB,EAAE,OAAuB;IACvE,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACnE,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;QACzB,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE;YACtC,OAAO,CAAC,CAAC;SACV;KACF;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC","file":"findindex.js","sourcesContent":["import { FindOptions } from './findoptions';\n\n/**\n * Returns the index of the first element in the array that satisfies the provided testing function.\n * Otherwise, it returns -1, indicating that no element passed the test.\n *\n * @export\n * @template T The type of the elements in the source sequence.\n * @param {Iterable<T>} source An iterable sequence whose elements to apply the predicate to.\n * @param {FindOptions<T>} options The options for a predicate for filtering, thisArg for binding and AbortSignal for cancellation.\n * @returns {number} The index of the first element in the array that passes the test. Otherwise, -1.\n */\nexport function findIndex<T>(source: Iterable<T>, options: FindOptions<T>): number {\n const { ['thisArg']: thisArg, ['predicate']: predicate } = options;\n let i = 0;\n\n for (const item of source) {\n if (predicate.call(thisArg, item, i++)) {\n return i;\n }\n }\n return -1;\n}\n"]}
\No newline at end of file