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

dahi

v1.0.12

Published

a port of kefir(frp) for js-csp

Downloads

18

Readme

(work in progress)

dahi

FRP + channels = max win.

a port of kefir for js-csp

npm install dahi

(these api docs are derived/modified from kefir)

create a channel

never() creates a channel that's already closed

later(wait) creates a channel that produces a single value after wait milliseconds, and then closes.

interval(wait, value) creates a channel that produces the same value each interval milliseconds, and never closes.

sequentially(interval, values) creates a channel containing the values, delivered with the given interval milliseconds, and then closes

fromPoll(interval, fn) creates a channel that polls the given fn function, with the given interval in milliseconds, and emits the values returned by fn. Never ends.

withInterval(interval, handler) creates a channel that calls the given handler function, with the given interval in milliseconds. The handler function is called with one argument — a channel.

fromCallback(callback) convert a function than accepts a callback as the first argument, to a channel. Emits at most one value when callback is called, then ends.

fromNodeCallback(callback) like fromCallback, but accepts a node style callback which gets arguments in the form (err, res).

fromEvents(emitter, event) returns a channel with every event from emitter

modify a channel

map(channel, fn) applies fn to every value in channel

filter(channel, predicate) applies predicate to every value in channel, and only allows truthy values to be passed on

takeWhile(channel, predicate) puts values from channel until predicate applied to a value returns false. Ends when predicate returns false.

flatten(channel) For this method it's expected that the channel 'emits' arrays. The result channel will then 'emit' each element of these arrays.

last(channel) returns a channel with only the last value from channel

skip(channel, n) drops the first n elements from channel and returns a channel with the rest

skipWhile(channel, predicate) Skips values from channel until the predicate applied to a value returns false, then stops applying predicate to values and 'emits' all of them.

skipDuplicates(channel) Skips duplicate values using === for comparison.

transduce(channel, xf) applies the transducer xf to every value in channel

diff(channel, fn, seed) On each value from channel, calls fn with the previous and current values as arguments. At first time, calls fn with seed and current value. Puts whatever fn returns. If no seed is provided, the first value will be used as a seed, and the result channel won't put the first value. If no fn function is provided, (a, b) => [a, b] will be used.

scan(channel, fn, seed) On each value from channel, calls fn with the previous result returned by fn and the current value put on the channel. At first time, calls fn with seed as previous result. Puts forward whatever fn returns. If no seed is provided, the first value will be used as a seed.

delay(ch, wait) Delays all takes by wait milliseconds.

debounce(ch, wait) debounces all takes by wait milliseconds.

throttle(ch, wait) throttles all takes by wait milliseconds.

bufferWhile(channel, predicate, flushOnEnd?) adds every value from channel to a buffer, and then passes it to to predicate(). If it returns false, then it flushes the buffer. Also flushes the buffer before end, but you can disable that by passing flushOnEnd as false.

combine channels

zip(...channels) Creates a channel with values from channels lined up with each other. For example if you have two channels with values [1, 2, 3] and [4, 5, 6, 7], the result channel will 'emit' [1, 4], [2, 5], and [3, 6]. The result channel will 'emit' the next value only when it has at least one value from each source channel.

concat(...channels) Concatenates several channels into one channel. Like csp.merge, but switches to the next source only after the previous one ends.

combine two channels

filterBy(chan, otherChan) Works like filter, but instead of calling a predicate on each value from chan, it checks the last value from otherChan.

sampledBy(chan, otherChan) Returns a channel that emits the latest value from chan on each value from otherChan. Closes when otherChan closes.

takeWhileBy(chan, otherChan) Works like csp.operations.takeWhile, but instead of using a predicate function it uses another channel. It takes values from chan until the first falsey value from otherChan.

takeUntilBy(chan, otherChan) Similar to takeWhileBy, but instead of waiting for the first falsey value from otherChan, it waits for just any value from it.

bufferBy(chan, otherChan, flushOnEnd=true) Buffers all values from chan, and flushes the buffer on each value from otherChan. Also flushes the buffer before end, but you can disable that by passing flushOnEnd as false.

log(chan) logs every put onto the channel

open issues

  • unfinished functions - list.md
  • accept custom chanopts per function
  • debounce immediate: true
  • combine combinators
  • audit putAsync usage
  • error handling story
  • fromPromise vs promiseChan
  • close from producer side on infinite channels