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

evented-chain

v1.0.0

Published

Chain async callbacks together; monitor progress with events

Downloads

4

Readme

evented-chain

Build Status Coverage Status NPM version Davis Dependency Status

Chain async callbacks together; monitor progress with events

example

var chain = require('evented-chain')

function double (x, cb) {
    cb(null, x * 2)
}

function square (x, cb) {
    cb(null, x*x)
}

var doubleSquare = chain(double, square)

doubleSquare(2, function (err, result) { console.log('callback got ' + result) })
    .on('step', function (step, args) {
        console.log('step '+step, 'result: ' + args[0])
    })
    .on('complete', function (args) {
        console.log('final value: ' + args[0])
    })

api

var chain = require('evented-chain')

fn = chain(fn1, fn2, fn3, ...)

chain returns a function (fn), that when called will execute the chained functions (fn1, fn2, ...) in a waterfall manner, where the result of previous functions are fed as arguments to the next function, until all functions have executed. Each function in the chain (fn1, fn2, etc) must accept an error-first style callback as it's last argument, and supply it's result to that callback.

Once the chain has completed executing, the final result will be passed to the (optional) callback provided to the generated function, fn.

If an error is passed to any callback, the final callback (fn) will be executed with the error immediately.

fn = chain([fn1, fn2, fn3, ...])

Same as above, but chain functions may be supplied to chain in an array instead of as arguments.

events

var progress = fn()

When the generated function is executed, an event emitter is returned. This emitter can be listened to for insight into the progress of the chain. Events emitted are:

  • step - For each chain function execited succesfully, this event is emitted with step, and args where step is the index of the function executed, and args is an array of arguments passed to that function.
  • fail - Emitted when a function executes it's callback with an error. This event is emitetd with step, err, and args where err contains the error passed to the callback, and args contains any other args passed.
  • complete - Emitted once the chain has finished executing. This event is emitted with args which contains an array of arguments passed to the final callback, minus the first (non-existant error) argument.

testing

npm test [--dot | --spec] [--coverage]

options

  • --dot - output test results as dots instead of tap
  • --spec - output test results as spec instead of tap
  • --coverage - display text cover report

patterns

Only run test files matching a certain pattern by prefixing the test command with grep=pattern. Example:

grep=connect npm test --dot

html coverage report

Open it with npm run view-cover or npm run vc