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 🙏

© 2026 – Pkg Stats / Ryan Hefner

async-call

v1.0.0

Published

Yet another async library for nodejs

Readme

async-call

Yet another async library for nodejs

Installation

npm install async-call

Methods

Flow control methods:

Working with collections:

Async methods expects callbacks to be in the following form

/**
 * @param {...*} args Zero or more parameters
 * @param {function(?*, ...*)} complete Called when method is complete
 */
var callback = function([args, ] complete) {
    if(ok) complete(null /*, results, ...*/); // pass 'null' explicitly if there is no errors
    else complete('error string, object, code, etc..');
};

sequence

Calls set of functions sequentially, passing result of one function to another

var foo = function(a, complete) {
    complete(null, a, 'bar');
};

var bar = function(a, b, complete) {
    complete(null, a + b);
};

async.sequence([foo, bar])('foo', function(err, result) {
    if (err) throw err;
    console.log(result); // foobar
});

series

Calls set of callbacks sequentially providing same initial arguments. Results are ignored

    var foo = function(a, complete) {
        console.log(a);
        complete(null, 'bar');
    };

    var bar = function(b, complete) {
        console.log(b);
        complete(null);
    };

    // outputs : foo foo
    async.series([foo, bar])('foo', function(err) {
        if (err) throw err;
    });

collect

Calls set of callbacks in parallel, providing same inital arguments and collecting values

    var foo = function(a, complete) {
        complete(null, a + 'foo');
    };

    var bar = function(b, complete) {
        complete(null, b + 'bar');
    };

    async.collect([foo, bar])('foo', function(err, res_foo, res_bar) {
        if (err) throw err;
        console.log(res_foo, res_bar); // foofoo foobar
    });

each

Applies callback for each element in the array

    var foo = function(a, complete) {
        complete(null, a + 'foo');
    };

    async.each(foo)(['1', '2', '3'], function(err, result) {
        if (err) throw err;
        console.log(result); // ['1foo', '2foo', '3foo']
    });

Features

Chaining

Methods can be chained together

var split = function(input, complete) {
    var parts = input.split(' ');
    complete(null, parts[0], parts[1]);
};

var buildArray = function(part1, part2, complete) {
    complete(null, [part1, part2]);
};

var addBaz = function(input, complete) {
    complete(null, input + 'baz');
};

var multiply = function(input, complete) {
    complete(null, input + input);
};

var join = function(input, complete) {
    var result = [];
    for (var i in input) result.push(input[i].join('+'));
    complete(null, result.join(' '));
};

var algorithm = async.sequence([
    split,
    buildArray,
    async.each(
        async.collect([
            addBaz,
            multiply
        ])
    ),
    join
]);


algorithm('foo bar', function(err, result) {
    console.log(result); // foobaz+foofoo barbaz+barbar
});

Reusing

Once chain of callbacks in defined, it can be reused with another set of parameters

var foo = function(a, complete) {
    complete(null, a + 'foo');
};

var bar = function(b, complete) {
    complete(null, b + 'bar');
};

var processing = async.sequence([foo, bar, bar]);

processing('foo', function(err, result) {
    if (err) throw err;
    console.log(result); // foofoobarbar
});

processing('bar', function(err, result) {
    if (err) throw err;
    console.log(result); // barfoobarbar
});

Passing context

Context applied to async method will be provided for all callbacks in the set

var foo = function(complete) {
    complete(null, this.foo);
};

var bar = function(arg, complete) {
    complete(null, arg + this.bar);
};

var sequence = async.sequence([foo, bar]);

sequence.call({foo : 'foo', bar : 'bar'}, function(err, result) {
    if (err) throw err;
    console.log(result); // foobar
});


sequence.call({foo:'bar', bar:'baz'}, function(err, result) {
    if (err) throw err;
    console.log(result); // barbaz
});