s-batch
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

s-batch

A transform stream that batches items into arrays.

Installation

npm install s-batch

Usage

import sBatch from "s-batch";

const batch = sBatch(3);

const result = await Array.fromAsync(
  ReadableStream.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).pipeThrough(batch)
);

console.log(result); // [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]

API

sBatch<T>(batchSize: number): TransformStream<T, T[]>

Returns a transform stream that batches items into arrays.

Package Sidebar

Install

npm i s-batch

Weekly Downloads

2,787

Version

1.0.1

License

MIT

Unpacked Size

2.65 kB

Total Files

5

Last publish

Collaborators

  • trevorah