npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rxjs-extra

v2.0.1

Published

Collection of extra RxJS 6 operators, Observable creation methods, Observers and Subjects for common use-cases.

Downloads

9

Readme

Build Status

RxJS Extra

Collection of extra RxJS 6 operators, Observable creation methods, Observers and Subjects for common use-cases.

List of Features

Operators

  • cache - Caches the source Observable values for a time period with three different caching strategies.
  • delayComplete - Just like delay() but delays only the complete notification.
  • errorWhen - Emits an error notification when a value matches the predicate function.
  • finalizeWithReason - Just like finalize() but passes to its callback also reason why the chain is being disposed.
  • queueTime - Mirrors the source Observable and makes at most timeDelay delay between two emissions to keep at least timeDelay intervals while re-emitting source asap.
  • randomDelay - Mirrors the source Observable but makes random delays between emissions on a specified scheduler.
  • retryTime - Just like retry() but resubscribes to its source Observable with constant delays or resubscribes only N times based on a predefined array of delays.
  • takeUntilComplete - Just like takeUntil() but completes only when the notifier completes and ignores all next notifications.
  • tapSubscribe - Triggers callback every time a new observer subscribes to this chain.

Observable creation methods

  • presetTimer - Creates an Observable that emits sequential numbers in predefined delays on a specified scheduler.
  • randomTimer - Creates an Observable that emits sequential numbers in random intervals on a specified scheduler.

Observers

  • DebugObserver - Observer for debugging purposes that timestamps each notification with time offset since the instance was created.

Subjects

  • PersistentSubject - Just like BehaviorSubject but stores every item in a persistent storage (LocalStorage by default).

Usage

Install rxjs-extra via npm:

npm install rxjs-extra

The general usage is the same as with any RxJS 6 operators or Observable creation methods:

In TypeScript for example:

import { map } from 'rxjs/operators';
import { randomTimer } from 'rxjs-extra';
import { tapSubscribe } from 'rxjs-extra/operators';

randomTimer(100, 2000).pipe(
  tapSubscribe(() => console.log('subscribed')),
  map(i => String.fromCharCode(97 + i)),
).subscribe(console.log);

In node environment for example:

const { map } = require('rxjs/operators');
const { randomTimer } = require('rxjs-extra');
const { tapSubscribe } = require('rxjs-extra/operators');

randomTimer(100, 2000).pipe(
  tapSubscribe(() => console.log('subscribed')),
  map(i => String.fromCharCode(97 + i)),
).subscribe(console.log);

Demos

All features from this package have their small demo examples written in TypeScript. You can use NPM demo script with preconfigures ts-node to run any one of them:

$ npm run demo -- demo/delayComplete.ts

Testing

This repository tests are based completely on RxJS marble tests and its helpers. You'll have to clone the original RxJS repo because tests in this repo rely on tools available only in the official RxJS 6 repo.

$ npm run clone_rxjs_repo

To run the test suit simply run the following npm script:

$ npm run test

This repository also uses the same marble2png generator as the original RxJS repo. Since this isn't an officially exported feature of RxJS 6 the process is a little more complicated but fully automatic by running a single script:

$ npm run tests2png_full

The tests2png_full script does the following things:

  1. Clones https://github.com/ReactiveX/rxjs.git repo into .rxjs-repo directory.

  2. Creates ./docs_app/content/img/ directory.

  3. Runs mocha tests with tests2png.opts options.

  4. Copies content of ./docs_app/content/img/ to ./doc.

  5. Removes temp directories .rxjs-repo and ./docs_app.

If you know you're about to run the png generator a lot you can just clone the RxJS repo and re-run the test suit:

$ npm run clone_rxjs_repo
$ npm run tests2png