stream-chain
Version:
Chain functions, generators, Node streams, and Web streams into a pipeline with backpressure support.
18 lines (14 loc) • 601 B
TypeScript
import {none} from '../defs.js';
/**
* Batch values into arrays of `n` elements.
*/
type BatchOutput<T> = (value: T | typeof none) => T[] | typeof none;
/**
* Creates a function that batches values into arrays of `n` elements.
* @param n number of elements in a batch
* @returns a flushable function that batches values
* @remarks The returned function is a {@link BatchOutput}. It collects values into batches (arrays) of `n` elements. The last batch can have less than `n` elements.
*/
declare function batch<T = unknown>(n?: number): BatchOutput<T>;
export default batch;
export {batch};