rxjs-drop-intermediate
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

rxjs-drop-intermediate

CircleCI codecov

RxJS operator to prevent congestion by dropping intermediate values. This can be useful when there are many events generated by user-input or a WebSocket connection where some intermediate events (e.g. updates from a certain channel) can be dropped.

Usage:

import { dropIntermediate } from 'rxjs-drop-intermediate';

const droppingObservable = source.pipe(dropIntermediate());

Example taken from integration tests:

const subject = new Subject<string>();
webSocket.onmessage = (m) => subject.next(m.data.toLocaleString());
const actual = await firstValueFrom(
  subject.pipe(
    dropIntermediate(),
    map((v) => parseInt(v)),
    tap(() => execSync('sleep 2')),
    take(2),
    toArray(),
    map((a) => a[1] - a[0])
  )
);

expect(actual).toBeGreaterThan(5);

Readme

Keywords

Package Sidebar

Install

npm i rxjs-drop-intermediate

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

34.7 kB

Total Files

15

Last publish

Collaborators

  • mlenger