method Stream.filterErr
Stream.filterErr<F extends E>(fn: (error: E) => error is F): Stream<T, F>

Similar to Array.prototype.filter, but works on the stream of errors. If the provided function throws an error or returns a rejected promise, the error will be collected and emitted as an error result in the stream.

Examples

Example 1

import { Stream } from "anabranch";

const stream = Source.from<number, string>(async function* () {
  yield 1;
  yield 2;
});

const filteredErrorStream = stream.filterErr(async (error) => {
  return error.includes("Value cannot be 2");
});

Type Parameters

F extends E

Parameters

fn: (error: E) => error is F

Return Type

Stream<T, F>

See

Stream.filterErr(fn: (error: E) => Promisable<boolean>): Stream<T, E>

Parameters

fn: (error: E) => Promisable<boolean>

Return Type

Stream<T, E>