UNPKG

943 BTypeScriptView Raw
1import { OptionalFindOptions } from './findoptions';
2/**
3 * Returns the only element of an async-iterable sequence that matches the predicate if specified,
4 * or undefined if no such element exists; this method reports an exception if there is more
5 * than one element in the async-iterable sequence.
6 *
7 * @export
8 * @template T The type of the elements in the source sequence.
9 * @param {AsyncIterable<T>} source Source async-iterable sequence.
10 * @param {OptionalFindOptions<T>} [options] The optional options which includes a predicate for filtering,
11 * thisArg for predicate binding and an abort signal for cancellation.
12 * @returns {(Promise<T | undefined>)} A promise with the single element in the async-iterable sequence that satisfies
13 * the condition in the predicate, or undefined if no such element exists.
14 */
15export declare function single<T>(source: AsyncIterable<T>, options?: OptionalFindOptions<T>): Promise<T | undefined>;