Mfind
Bun

method

crypto.Hmac.find

find<T>(
fn: (data: any, options?: Abortable) => data is T,
options?: Pick<ReadableOperatorOptions, 'signal' | 'concurrency'>
): Promise<undefined | T>;

This method is similar to Array.prototype.find and calls fn on each chunk in the stream to find a chunk with a truthy value for fn. Once an fn call's awaited return value is truthy, the stream is destroyed and the promise is fulfilled with value for which fn returned a truthy value. If all of the fn calls on the chunks return a falsy value, the promise is fulfilled with undefined.

@param fn

a function to call on each chunk of the stream. Async or not.

@returns

a promise evaluating to the first chunk for which fn evaluated with a truthy value, or undefined if no element was found.

fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
options?: Pick<ReadableOperatorOptions, 'signal' | 'concurrency'>
): Promise<any>;

This method is similar to Array.prototype.find and calls fn on each chunk in the stream to find a chunk with a truthy value for fn. Once an fn call's awaited return value is truthy, the stream is destroyed and the promise is fulfilled with value for which fn returned a truthy value. If all of the fn calls on the chunks return a falsy value, the promise is fulfilled with undefined.

@param fn

a function to call on each chunk of the stream. Async or not.

@returns

a promise evaluating to the first chunk for which fn evaluated with a truthy value, or undefined if no element was found.