push-stream-std

@push-stream-std/push-notify (0.0.8)

Published 2026-07-21 03:59:36 +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-notify@0.0.8
"@push-stream-std/push-notify": "0.0.8"

About this package

@push-stream-std/push-notify

Observable-like source that broadcasts values to multiple listeners.

Published as @push-stream-std/push-notify.

Synopsis

import notify from '@push-stream-std/push-notify';
import concat from '@push-stream-std/push-concat';

const notifier = notify();

notifier.listen().pipe(concat((err, result) => {
  console.log('listener 1:', result); // [1, 2]
}));

notifier.listen().pipe(concat((err, result) => {
  console.log('listener 2:', result); // [1, 2]
}));

notifier(1);
notifier(2);
notifier.end();

Direct piping:

const sink = concat((err, result) => console.log(result));
notifier.pipe(sink);
notifier(42);
notifier.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-notify

Why

A broadcast source that emits values to all piped listeners. Each call to notify.listen() returns a new source stream that receives future values — new listeners do not receive past values. Backpressure is respected: if any listener is paused, all listeners buffer until the paused listener resumes. Calling notifier.end(err) terminates all listeners.

API

notify()

Creates a notifier.

  • Returns A function notifier(value) that also has .listen(), .end(), and .pipe() methods.

notifier(value)

Push a value to all piped listeners.

  • Returns true if all listeners accepted the value without buffering, false if buffering occurred.

notifier.listen()

Create a new listener source.

  • Returns A source stream that receives future broadcasts. Can be piped to sinks.

notifier.end(err?)

End all listeners.

notifier.pipe(sink)

Create a listener and pipe it directly to a sink.

Tests

npm test

Tests cover broadcasting to multiple listeners, listener creation/removal, end propagation, backpressure buffering, and aborted listeners.

Requirements

Node.js 22 or later. ESM only.

Dependencies

Dependencies

ID Version
@push-stream-std/push-stream-base *

Development Dependencies

ID Version
fast-check ^3.23.2

Keywords

push-stream stream notify event-emitter
Details
npm
2026-07-21 03:59:36 +00:00
1
SEE LICENSE IN LICENSE
latest
3.9 KiB
Assets (1)
Versions (5) View all
0.0.8 2026-07-21
0.0.7 2026-07-20
0.0.6 2026-07-20
0.0.5 2026-07-19
0.0.3 2026-07-19