@metreeca/pipe - v0.9.11
    Preparing search index...

    Function batch

    • Creates a task grouping items into batches of a specified size.

      Items are processed sequentially and order is preserved both across batches and within each batch.

      If size is 0 or negative, collects all items into a single batch. The final batch may contain fewer items than the specified size.

      Type Parameters

      • V

        The type of items in the stream

      Parameters

      • size: number = 0

        The maximum number of items per batch (0 or negative for unbounded)

      Returns Task<V, readonly V[]>

      A task that groups items into batches

      0
      

      When size is 0 or negative, all stream items are accumulated in memory before yielding a single batch. For large or infinite streams, this may cause memory issues. Use a positive size for bounded memory consumption.