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

rxify

v0.9.2

Published

An RxJS library wrapper that lets you execute Rx operators directly using marble-diagram ASCII string arguments.

Downloads

8

Readme

rxify

An RxJS library wrapper that lets you execute Rx operators directly using marble-diagram ASCII string arguments.

rxify was mainly created as an educational tool to guide those ramping up on Reactive Extensions for the first time by presenting an alternative way to visualize and experiment on its asynchronous features. However, some folks may find it useful for other purposes such as general problem-solving or simplifying unit tests.

Installation
npm install rxify
Marble Notation / Terminology

Each string argument is basically an observable sequence expressed in ASCII marble diagram notation. For example, the string 'A...B' represents a stream of two events separated by some passage of time. In rxify the actual unit of time is not important, so it may be easier to just imagine each '.' as one tick of time. Also, to simplify things further, the end of a string is automatically interpreted as an onCompleted action. Technically you can represent that with '|' but it's purely optional.

|Sequence Character | Meaning | | :------------- | :------------- | | . | One tick of elapsed time | | | | onCompleted() event | | ! | onError() event | | ( ) | A grouped set of coinciding events | | A-Z, 0-9 | onNext() event |

Basic Examples

The easiest way to convert a marble string directly to an observable is to call rxify.of, rxify.just, or rxify.from:

var rxify = require('rxify');
var obs = rxify.of('A...B...');
obs = rxify.just('A...B...');
obs = rxify.from('A...B...');
console.log(obs.toString());
// Output: 'A...B...'

You can also pass these strings directly in as normal arguments:

obs = rxify.concat('A...','B...','C...');
console.log(obs.toString());
// Output: 'A...B...C...'
Chaining Operators
obs = rxify.of('A...B...').concat('C...')
console.log(obs.toString());
// Output: 'A...B...C...'
obs = rxify.zip('A...B...C...','123').take(2);
console.log(obs.toString());
// Output: '(A1)...(B2)'
Visualizing Output

If you'd like to see a verbose colorized step-by-step breakdown on a chained set of operations, you can call the extended display() method.

obs = rxify.zip('A...B...C...','123').take(2);
obs.display();
// Outputs:
// OPERATION ARGUMENTS              OUTPUT
// zip       ["A...B...C...","123"] (A1)...(B2)...(C3)...|
// take      [2]                    (A1)...(B2)|

Dealing with Time

Note: When calling a RxJS operator that normally expects a time-based argument in milliseconds, with rxify you should instead pass in the desired number of ticks. For example:

rxify.delay(3) // Interpreted as '...'

Note: You can also represent the argument as a sequence string:

rxify.delay('...')
More Examples
var seqa = 'A...B.....C';
var seqb = '..1...2.3..';
var seqc = 'x....y....z';
var obs = rxify.combineLatest(seqa, seqb, seqc );
console.log(obs.toString());
// Output: '..(A1x).(B1x)(B1y)(B2y).(B3y).(C3z)'
var i = 0;
console.log('doWhile example: ' + rxify.from('Aa.').
            doWhile(function() {
                return ++i <= 4;
            })
);
// Output: 'doWhile example: Aa.Aa.Aa.Aa.Aa.'
var seq = '123456789';
console.log('filter example: ' + rxify.from(seq).
    filter(function(elem) {
        return elem % 2 == 0;
    })
);
// Output: 'filter example: .2.4.6.8.'
console.log('bufferWithTime example: ' + rxify.interval(1).
    bufferWithTime(5,1).
    take(3)
);
// Output: 'bufferWithTime: ....(0,1,2,3,4)(0,1,2,3,4,5)(2,3,4,5,6)'
var input = 'AA..BBB..CCCC...DDDD...EEEEEE..FFFFF..GGGGG';
console.log('debounce example: ' + rxify.of(input).debounce(1).toString());
// Output: '..A....B.....C......D........E......F.....G'

If you'd like more examples on how to use rxify, please refer to these unit tests

Supported Observable Methods

  • amb
  • catch
  • combineLatest
  • concat
  • empty
  • for
  • forkJoin
  • from
  • generate
  • if
  • interval
  • just
  • merge
  • mergeDelayError
  • of
  • onErrorResumeNext
  • pairs
  • range
  • repeat
  • return
  • start
  • timer
  • while
  • zip

Supported Observable Instance Methods

  • average
  • bufferWithCount
  • bufferWithTime
  • catch
  • combineLatest
  • concat
  • count
  • debounce
  • defaultIfEmpty
  • delay
  • distinct
  • distinctUntilChanged
  • do
  • doOnCompleted
  • doOnError
  • doOnNext
  • doWhile
  • elementAt
  • every
  • filter
  • finally
  • find
  • findIndex
  • first
  • flatMap
  • flatMapLatest
  • forEach
  • forkJoin
  • ignoreElements
  • isEmpty
  • last
  • let
  • map
  • max
  • maxBy
  • merge
  • min
  • minBy
  • onErrorResumeNext
  • pairwise
  • pluck
  • reduce
  • retry
  • sample
  • scan
  • select**
  • selectMany
  • sequenceEqual
  • skip
  • skipLast
  • skipLastWithTime
  • skipUntil
  • skipUntilWithTime
  • skipWhile
  • some
  • startWith
  • subscribe
  • subscribeOnCompleted
  • subscribeOnError
  • subscribeOnNext
  • sum
  • take
  • takeLast
  • takeLastBuffer
  • takeLastBufferWithTime
  • takeLastWithTime
  • takeUntil
  • takeUntilWithTime
  • takeWhile
  • tap
  • tapOnCompleted
  • tapOnError
  • tapOnNext
  • throttle
  • timeout
  • timeInterval
  • timestamp
  • toArray
  • where
  • zip