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

rx-utils

v2.0.2

Published

High-level RxJS utils

Downloads

21

Readme

RxJS utils

High-level RxJS operators.

Legend

stateless stream: --x--y-->
stateful stream:  ==x==y==>

Stateless stream is a stream of events. Stateful stream is a stream of data having the value "between" the events. Stateful streams in RxJS can be made by statelessStream.shareReplay(1).

Dependencies

  • RxJS (peer)

Here and below Rx.Observable type may be aliased as Obs and its instances as O for brevity.

API

passIfHigh :: Obs b -> Obs a -> Obs a

Passes values from a$ further when b$ is truthy.

Example: TODO

passIfLow :: Obs b -> Obs a -> Obs a

Passes values from a$ instance further when b$ is falsy.

Example: TODO

passIfUp :: Obs b -> Obs a -> Obs a

Passes values from a$ further when b$ is truthy, including the switch moment.

Example: TODO

passIfDown :: Obs b -> Obs a -> Obs a

Passes values from a$ further when b$ is falsy, including the switch moment.

Example:

state
  .let(passIfDown(lock))

// lock:   1==========0=========>
// state:  ---s1---s2------s3--->
// result: -----------s2---s3--->

mergeObj :: Object (Obs *) -> Obs *

Merges an object of streams to a stream of objects.

Example:

// Describe reactive state declaratively
let actions = {
  inc: O.of(c => c + 1).delay(1000),
  dec: O.of(c => c - 1).delay(2000),
}

let state = mergeObj(actions)
 .startWith(seed)
 .scan((state, fn) => fn(state))
 .shareReplay(1)

// inc:   ------f------->
// dec:   ----------f--->
// state: 0=====1===0===>

combineLatestObj :: Object (Obs *) -> Obs *

Combines an object of streams to a stream of objects.

Example:

// Update React(-like) props whenever stateful streams change
let streamsToProps = {
  counterX: db$.pluck("counterX"),
  counterY: db$.pluck("counterY"),
}

combineLatestObj(streamsToProps)
  .throttleTime(10)
  .subscribe((data) => {
    this.setState(data)
  })

// counterX: ===x1========x2===>
// counterY: ========y1========>
// result:   ---!----!----!---->

mergeObjTracking :: Object (Obs *) -> Obs {key :: String, value :: *}

Merges an object of streams to a stream of objects, keeping the original key data.

Example:

// Track the actions
let actions = {
  add: O.of(1, 2).concatMap((fn, i) => O.of(fn).delay(1000)),
  sub: O.of(3, 4).delay(2000).concatMap((fn, i) => O.of(fn).delay(1000)),
}

let track = mergeObjTracking(actions)
track.subscribe(pack => {
  console.log(pack.key + "(" + pack.data + ")")
})

// add(1)
// add(2)
// sub(3)
// sub(4)

chan :: (Obs a -> Obs b) -> Obs (a -> b)

Overloaded: chan :: a -> ()

Makes a callable observable.

Example: TODo

License

MIT