@push-stream-std/push-paramap (0.0.5)
Published 2026-07-20 18:59:58 +00:00 by Dvorak
Installation
@push-stream-std:registry=https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/npm install @push-stream-std/push-paramap@0.0.5"@push-stream-std/push-paramap": "0.0.5"About this package
push-paramap
Parallel async map with configurable concurrency, maintaining output order.
Published as @push-stream-std/push-paramap.
Synopsis
import paraMap from '@push-stream-std/push-paramap';
import pushable from '@push-stream-std/push-pushable';
import concat from '@push-stream-std/push-concat';
const source = pushable();
source.pipe(paraMap((value, cb) => {
setTimeout(() => cb(null, value * 2), 10);
}, 4)).pipe(concat((err, result) => {
if (err) return console.error(err);
console.log(result); // [2, 4, 6, 8]
}));
source.push(1);
source.push(2);
source.push(3);
source.push(4);
source.end();
Install
npm config set @push-stream-std:registry https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/
npm config set -- //hub.kl1.tenere.ai/api/packages/push-stream-std/npm/:_authToken "$PACKAGE_TOKEN"
npm install @push-stream-std/push-paramap
Description
A through stream that maps each value through an async callback, processing up to width items concurrently. Results are emitted in the original input order regardless of completion order. Each mapper receives (value, callback) and must call callback(err, result). Errors from any mapper terminate the stream immediately.
API
paraMap(mapper, width?)
Creates a parallel map through stream.
- mapper
(value, cb: (err, result) => void) => void– Async map function. Called with each value and a callback. If the callback receives an error, the stream ends with that error. - width
number(defaultInfinity) – Maximum number of in-flight mapper invocations. - Returns A through stream with
pipe(),resume(),abort(),write(),end(),paused, andended.
Tests
npm test
Tests cover parallel execution with concurrency limit, output ordering preservation, error propagation from mapper callbacks, and end after all pending mappers complete.
Requirements
Node.js 18 or later. ESM only.
License
MIT
Keywords
push-stream
stream
paramap
parallel
async