push-stream-std

@push-stream-std/push-with-latest-from (0.0.3)

Published 2026-07-19 21:14:33 +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-with-latest-from@0.0.3
"@push-stream-std/push-with-latest-from": "0.0.3"

About this package

push-with-latest-from

Combine a primary source with the latest values from auxiliary sources.

Published as @push-stream-std/push-with-latest-from.

Synopsis

import withLatestFrom from '@push-stream-std/push-with-latest-from';
import pushable from '@push-stream-std/push-pushable';

const primary = pushable();
const aux = pushable();

const combined = withLatestFrom(aux);

const sink = {
  paused: false,
  write(v) { console.log('tuple:', v); },
  end() { console.log('done'); }
};

primary.pipe(combined).pipe(sink);

aux.push('latest from aux');
primary.push(1);
// Output: tuple: [1, 'latest from aux']
primary.push(2);
// Output: tuple: [2, 'latest from aux']

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-with-latest-from

Description

A through stream that subscribes to one or more auxiliary sources. When the primary source emits a value, it is combined with the latest value from each auxiliary source into an array [primaryValue, ...auxValues]. Emissions are suppressed until every auxiliary source has produced at least one value. Auxiliary sources are wired up during pipe(), proxied so their values are captured without flowing through the main sink until the primary fires.

API

withLatestFrom(...sources)

Creates a with-latest-from through stream.

  • sources ...PushStreamSource – One or more auxiliary push-stream sources. Values from these are cached.
  • Returns A through stream with pipe(), write(), end(), abort(), resume(), paused, and ended. Piped sink receives [primaryValue, ...latestAuxValues] arrays.

Tests

npm test

Tests cover tuple emission with latest aux values, suppressed emission before aux sources have data, multiple aux sources, and abort propagation to proxied sources.

Requirements

Node.js 18 or later. ESM only.

License

MIT

Keywords

push-stream with-latest-from combine latest
Details
npm
2026-07-19 21:14:33 +00:00
0
SEE LICENSE IN LICENSE
3.5 KiB
Assets (1)
Versions (7) View all
0.0.10 2026-07-21
0.0.9 2026-07-21
0.0.8 2026-07-20
0.0.7 2026-07-20
0.0.6 2026-07-19