filter<A> function

TaskOption<A> Function(TaskOption<A> taskOption) filter<A>(
  1. bool predicate(
    1. A value
    )
)

Conditionally transform the TaskOption to a None, using the given predicate.

expect(
  await some(10).chain(filter((i) => i > 5))(),
  O.some(10),
);
expect(
  await some(3).chain(filter((i) => i > 5))(),
  O.none(),
);

Implementation

TaskOption<A> Function(TaskOption<A> taskOption) filter<A>(
  bool Function(A value) predicate,
) =>
    (fa) => TaskOption(fa.p(T.map(O.filter(predicate))));