@push-stream-std/push-pairs (0.0.5)
Published 2026-07-20 18:59:57 +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-pairs@0.0.5"@push-stream-std/push-pairs": "0.0.5"About this package
push-pairs
Emit consecutive value pairs from a stream.
Published as @push-stream-std/push-pairs.
Synopsis
import pairs from '@push-stream-std/push-pairs';
import pushable from '@push-stream-std/push-pushable';
import concat from '@push-stream-std/push-concat';
const source = pushable();
source.pipe(pairs()).pipe(concat((err, result) => {
if (err) return console.error(err);
console.log(result); // [[1, 2], [2, 3], [3, 4]]
}));
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-pairs
Description
A through stream that transforms a sequence of values into consecutive overlapping pairs. Given input 1, 2, 3, 4, the output is [1,2], [2,3], [3,4]. The first value is buffered until the second arrives, so a single value produces no output. This is the push-stream equivalent of pull-stream's pull-pairs.
API
pairs()
Creates a through stream.
- Returns A through stream (both source and sink) with
pipe(),resume(),abort(),write(),end(),paused, andended.
The returned object can be used in a pipe chain: source.pipe(pairs()).pipe(sink).
Tests
npm test
Tests cover pair emission for odd and even-length streams, preserving original order, abort propagation, and empty/single-value streams.
Requirements
Node.js 18 or later. ESM only.
License
MIT
Keywords
push-stream
stream
pairs
consecutive