UNPKG

1.83 kBSource Map (JSON)View Raw
1{"version":3,"sources":["asynciterable/some.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAI,MAAwB,EAAE,OAAuB;IAC7E,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACvF,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;QACtD,IAAI,MAAM,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE;YACpD,OAAO,IAAI,CAAC;SACb;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC","file":"some.js","sourcesContent":["import { wrapWithAbort } from './operators/withabort';\nimport { throwIfAborted } from '../aborterror';\nimport { FindOptions } from './findoptions';\n\n/**\n * Determines whether any element of an async-iterable sequence satisfies a condition.\n *\n * @export\n * @template T The type of the elements in the source sequence.\n * @param {AsyncIterable<T>} source An async-iterable sequence whose elements to apply the predicate to.\n * @param {FindOptions<T, S>} options The options which includes a required predicate, an optional\n * thisArg for binding, and an abort signal for cancellation.\n * @returns {Promise<boolean>} A promise with a boolean determining whether any elements in the source sequence\n * pass the test in the specified predicate.\n */\nexport async function some<T>(source: AsyncIterable<T>, options: FindOptions<T>): Promise<boolean> {\n const { ['signal']: signal, ['thisArg']: thisArg, ['predicate']: predicate } = options;\n throwIfAborted(signal);\n let i = 0;\n for await (const item of wrapWithAbort(source, signal)) {\n if (await predicate.call(thisArg, item, i++, signal)) {\n return true;\n }\n }\n return false;\n}\n"]}
\No newline at end of file