web-stream-kit
    Preparing search index...

    Class FilterStream<T, S>

    A TransformStream that filters incoming chunks based on a sync or async predicate.

    const evens = numbersStream.pipeThrough(
    new FilterStream((n: number) => n % 2 === 0)
    );

    Type Parameters

    • T

      The type of input items.

    • S extends T = T

      The narrowed type of passing items, defaulting to T.

    Hierarchy

    • TransformStream<T, S>
      • FilterStream
    Index
    • Constructs a new FilterStream.

      Type Parameters

      • T

        The type of input items.

      • S = T

        The narrowed type of passing items, defaulting to T.

      Parameters

      • predicate: (chunk: T, index: number) => boolean | Promise<boolean>

        Predicate function returning true for items to pass through.

      Returns FilterStream<T, S>

    readable: ReadableStream<S>

    The readable read-only property of the TransformStream interface returns the ReadableStream instance controlled by this TransformStream.

    MDN Reference

    writable: WritableStream<T>

    The writable read-only property of the TransformStream interface returns the WritableStream instance controlled by this TransformStream.

    MDN Reference