push-stream-std

@push-stream-std/push-paramap (0.0.7)

Published 2026-07-21 03:59:49 +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.7
"@push-stream-std/push-paramap": "0.0.7"

About this package

@push-stream-std/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

Why

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 (default Infinity) – Maximum number of in-flight mapper invocations.
  • Returns A through stream with pipe(), resume(), abort(), write(), end(), paused, and ended.

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 22 or later. ESM only.

Keywords

push-stream stream paramap parallel async
Details
npm
2026-07-21 03:59:49 +00:00
0
SEE LICENSE IN LICENSE
latest
3.7 KiB
Assets (1)
Versions (5) View all
0.0.7 2026-07-21
0.0.6 2026-07-20
0.0.5 2026-07-20
0.0.4 2026-07-19
0.0.3 2026-07-19