effect-io-ai

Package: effect
Module: Sink

Sink.find

Creates a sink containing the first value matched by a synchronous predicate.

When to use

Use to scan stream input until the first matching element is found and return that element as an Option.

Details

Returns Option.none if the upstream stream ends before a match is found. Refinement predicates narrow the returned value type. The matching input is consumed; any later elements from the same pulled array are returned as leftovers.

See

Signature

declare const find: { <In, Out extends In>(refinement: Refinement<In, Out>): Sink<Option.Option<Out>, In, In>; <In>(predicate: Predicate<In>): Sink<Option.Option<In>, In, In>; }

Source

Since v4.0.0