push-stream-std

@push-stream-std/push-exhaust-map (0.0.4)

Published 2026-07-19 23:31: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-exhaust-map@0.0.4
"@push-stream-std/push-exhaust-map": "0.0.4"

About this package

push-exhaust-map

Ignore new values while inner stream is active.

Published as @push-stream-std/push-exhaust-map.

Synopsis

import { exhaustMap } from '@push-stream-std/push-exhaust-map';
import { values } from '@push-stream-std/push-values';
import { collect } from '@push-stream-std/push-collect';

const source = values([1, 2, 3]);
const mapped = exhaustMap((n) => {
  return values([n * 10, n * 100]);
});

collect(source.pipe(mapped), (err, result) => {
  console.log(result); // [10, 100] — 2 and 3 are dropped while inner is active
});

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-exhaust-map

Description

A through stream that maps each value to an inner stream, then ignores (drops) incoming values while the inner stream is active. Once the inner stream ends, the next pending value triggers a new inner stream. This prevents overlapping operations — useful for save-on-submit buttons, guaranteed single-flight requests, or any scenario where concurrent inner streams should be avoided.

API

exhaustMap(mapper)

Returns a through stream that maps values to inner streams, dropping incoming values while an inner stream is active.

  • mapper (value) => result — A function called with each accepted value. Can return:
    • A push-stream source (piped as inner stream)
    • An array (items written downstream immediately)
    • Any other value (written downstream as a single value)
  • Returns through — A push-stream through. Values arriving while an inner stream is active are buffered; only the most recent pending value is used when the inner stream completes. Earlier pending values are dropped.

Tests

npm test

Tests cover inner stream mapping, value drop while inner active, array mapper results, scalar mapper results, and abort/end propagation.

Requirements

Node.js 18 or later. ESM only.

License

MIT

Keywords

push-stream stream exhaustMap map debounce
Details
npm
2026-07-19 23:31:33 +00:00
0
MIT
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