s-batch
Version:
A transform stream that batches items into arrays
30 lines (18 loc) • 499 B
Markdown
A transform stream that batches items into arrays.
```bash
npm install s-batch
```
```js
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]]
```
Returns a transform stream that batches items into arrays.