Web streams utils - v0.3.0
    Preparing search index...

    Function batch

    • Batch chunks into arrays of specified size

      Type Parameters

      • T

      Parameters

      • size: number

        The size of each batch

      Returns TransformStream<T, T[]>

      A TransformStream that groups chunks into batches

      const stream = readable.pipeThrough(batch(3));
      // If readable emits [1, 2, 3, 4, 5], the result will be [[1, 2, 3], [4, 5]]