UNPKG

1.32 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/find.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAAI,MAAmB,EAAE,OAAuB;IAClE,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,IAAI,CAAC;SACb;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","file":"find.js","sourcesContent":["import { FindOptions } from './findoptions';\n\n/**\n * Returns the value of the first element in the provided iterable that satisfies the provided testing function.\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 {(T | undefined)} The first element that matches the predicate.\n */\nexport function find<T>(source: Iterable<T>, options: FindOptions<T>): T | undefined {\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 item;\n }\n }\n return undefined;\n}\n"]}
\No newline at end of file