Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@btapai/custom-rxjs-operators

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@btapai/custom-rxjs-operators

A library for my custom rxjs operators

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@btapai/custom-rxjs-operators

A collection of useful rxjs operators created by Balázs Tápai.

FILO Queue

First in, last out queue operator.

import { timer, from } from 'rxjs';
import { take } from 'rxjs/operators';
import { filoQueue } from '@btapai/custom-rxjs-operators';

const source$ = from([1, 2, 3, 4, 5]);
const emitter$ = timer(0, 1000).pipe(take(6));

source$.pipe(filoQueue(emitter$)).subscribe(res => {
  console.log(res);
});
// emits in reverse order:
// 5 after 1 sec
// 4 after 2 sec
// 3 after 3 sec
// 2 after 4 sec
// 1 after 5 sec
// undefined

Takes a source observable, and an emitter observable. The result observable emits every time when the emitter observable emits. It always emits the value that was last added to the queue.

If the queue is empty, but the emitter emits, the result observable emits undefined.

If the emitQueue property in the passed configuration is set to true, the result observable emits every time when the queue changes.

import { timer, from } from 'rxjs';
import { take } from 'rxjs/operators';
import { filoQueue } from '@btapai/custom-rxjs-operators';

const source$ = from([1, 2, 3, 4, 5]);
const emitter$ = timer(0, 1000).pipe(take(6));

source$.pipe(filoQueue(emitter$, { emitQueue: true })).subscribe(res => {
  console.log(res);
});

// [1]
// [1, 2]
// [1, 2, 3]
// [1, 2, 3, 4]
// [1, 2, 3, 4, 5]
// [1, 2, 3, 4]
// [1, 2, 3]
// [1, 2]
// [1]
// []
// []

FIFO Queue

First in, first out queue operator.

import { timer, from } from 'rxjs';
import { take } from 'rxjs/operators';
import { fifoQueue } from '@btapai/custom-rxjs-operators';

const source$ = from([1, 2, 3, 4, 5]);
const emitter$ = timer(0, 1000).pipe(take(6));

source$.pipe(fifoQueue(emitter$)).subscribe(res => {
  console.log(res);
});
// emits in reverse order:
// 1 after 1 sec
// 2 after 2 sec
// 3 after 3 sec
// 4 after 4 sec
// 5 after 5 sec
// undefined

Takes a source observable, and an emitter observable. The result observable emits every time when the emitter observable emits. It always emits the value that was first added to the queue.

If the queue is empty, but the emitter emits, the result observable emits undefined.

If the emitQueue property in the passed configuration is set to true, the result observable emits every time when the queue changes.

import { timer, from } from 'rxjs';
import { take } from 'rxjs/operators';
import { fifoQueue } from '@btapai/custom-rxjs-operators';

const source$ = from([1, 2, 3, 4, 5]);
const emitter$ = timer(0, 1000).pipe(take(6));

source$.pipe(fifoQueue(emitter$, { emitQueue: true })).subscribe(res => {
  console.log(res);
});

// [1]
// [1, 2]
// [1, 2, 3]
// [1, 2, 3, 4]
// [1, 2, 3, 4, 5]
// [1, 2, 3, 4]
// [1, 2, 3]
// [1, 2]
// [1]
// []
// []

FAQs

Package last updated on 11 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc