@johngw/stream
Version:
Reactive programming tools using the WHATWG Streams API.
29 lines (28 loc) • 713 B
text/typescript
import { Predicate } from '@johngw/stream-common/Function';
/**
* Call the predicate on each chunk in the queue.
* The first chunk to pass the predicate will be queued
* and the stream will be terminated.
*
* @group Transformers
* @example
* ```
* --1--2--3--4--5--6-X
*
* find((x) => x === 6)
*
* -----------------6-|
* ```
*
* Using type guards will extract the types you want to work with.
*
* ```
* --A--A--A--B--X
*
* find((x): x is B => x.type === 'b')
*
* -----------B--|
* ```
*/
export declare function find<In, Out extends In>(predicate: (chunk: In) => chunk is Out): TransformStream<In, Out>;
export declare function find<In>(predicate: Predicate<In>): TransformStream<In, In>;