web-stream-kit
    Preparing search index...

    Class BatchStream<T>

    A TransformStream that accumulates incoming items into arrays of a fixed size or flushes early if an optional maximum wait duration elapses.

    const batched = readable.pipeThrough(
    new BatchStream<number>({ batchSize: 100, maxWaitMs: 500 })
    );

    Type Parameters

    • T

      The type of items flowing through the stream.

    Hierarchy

    • TransformStream<T, T[]>
      • BatchStream
    Index
    • Constructs a new BatchStream.

      Type Parameters

      • T

        The type of items flowing through the stream.

      Parameters

      Returns BatchStream<T>

      If batchSize is less than or equal to 0.

    readable: ReadableStream<T[]>

    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