effect-io-ai

Package: effect
Module: Cause

Cause.filter

Preserves parts of a Cause that match a given predicate.

Details

This function allows you to retain only the parts of a Cause structure that match a specified predicate or refinement. Any parts of the Cause that do not match the provided condition are excluded from the result.

You can use this function in two ways:

This is useful when you need to extract specific types of errors, defects, or interruptions from a Cause while discarding unrelated parts.

Signature

declare const filter: { <E, EB extends E>(refinement: Refinement<Cause<NoInfer<E>>, Cause<EB>>): (self: Cause<E>) => Cause<EB>; <E>(predicate: Predicate<Cause<NoInfer<E>>>): (self: Cause<E>) => Cause<E>; <E, EB extends E>(self: Cause<E>, refinement: Refinement<Cause<E>, Cause<EB>>): Cause<EB>; <E>(self: Cause<E>, predicate: Predicate<Cause<E>>): Cause<E>; }

Source

Since v2.0.0