push-stream-std

@push-stream-std/push-pairs (0.0.6)

Published 2026-07-20 21:38:16 +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.6
"@push-stream-std/push-pairs": "0.0.6"

About this package

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

Why

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, and ended.

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

Keywords

push-stream stream pairs consecutive
Details
npm
2026-07-20 21:38:16 +00:00
0
SEE LICENSE IN LICENSE
3.1 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