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

microasync

v1.0.3

Published

Tiny library designed to handle async problems

Readme

microasync

Tiny library (~ 5kb) designed to handle famous async problems, focusing on what really matter.

There is no reason to use a library with tons of different methods when you usually will use only one or two of them.

Installation

For nodejs projects

npm install --save microasync

To use microasync in the browser download the minified file inside the dist folder.

Documentation

each(arr, function, [callback])

Iterate over array elements applying each element as a parameter of the specified function in "parallel".

Arguments

  • arr - Arary to iterate over.
  • function(el, callback) - A function to apply to each item in arr.
  • callback(err, result) - A callback which is called when all functions have finished, or an error occurs.

Examples

var filesArr = ['file1', 'file2', 'file3'];
microasync.each(filesArr, function(file, callback) {
    //open the file and do something
    ...
}, function(err){
  // if any call produced an error, err != null
});

map(arr, function, [callback])

Produces a new collection of values by mapping each element in arr through the function.

Arguments

  • arr - Array to iterate over.
  • function(el, callback) - A function to apply to each item in arr.
  • callback(err, result) - A callback which is called when all functions have finished, or an error occurs.

Example

var filesArr = ['file1', 'file2', 'file3'];
microasync.map(filesArr, function(file, callback) {
  fileContent =  ... open file ...
  callback(null, fileContent);
}, function(err, response){
  //response is an array with all file contents
});

filter(arr, function, [callback])

Returns a new array of all valid elements in arr. The response in array will be in the same order as the original.

Arguments

  • arr - Array to iterate over.
  • function(item, callback) - A truth test to apply to each item in arr.
  • callback(err, result) - A callback which is called when all functions have finished, or an error occurs.

Example

var filesArr = ['file1', 'file2', 'file3'];
microasync.filter(filesArr, function(file, callback) {
    isFile = ...check if file exists ...
    callback(null, isFile);
}, function(err, response){
    // response is an array of the existing files
});

series(tasks, [callback])

Run the functions in tasks in series, each one running once the previous function has completed.

Arguments

  • tasks - An array containing functions to run, each function is passed a callback(err, result) it must call on completion with an error err (which can be null) and an optional result value.
  • callback(err, response) - Run once all the functions have completed. This function gets a response array containing all the result arguments passed to the functions callbacks.

Example

microasync.series([
    function(callback){
        ...
        ..
        callback(null, 'foo');
    },
    function(callback){
        ...
        ..
        callback(null, 'bar');
    }
],
function(err, response){
    // response =['foo', 'bar']
});

parallel(tasks, [callback])

Run the functions in tasks in "parallel", without waiting until the previous function has completed.

Arguments

  • tasks - An array containing functions to run.
  • callback(err, response) - Is executed once all the functions have completed successfully.

Example

microasync.parallel([
    function(callback){
        setTimeout(function(){
            callback(null, 'foo');
        }, 500);
    },
    function(callback){
        setTimeout(function(){
            callback(null, 'bar');
        }, 250);
    }
],
function(err, response){
    // response = ['foo','bar']
});

waterfall(tasks, [callback])

Run the functions in tasks in series, each passing their response to the next function in the array.

Arguments

  • tasks - An array of functions to run, each function is passed a callback(err, result1, result2, ...) it must call on completion.
  • callback(err, [response]) - An callback to run once all the functions have completed.

Example

microasync.waterfall([
    function(callback) {
        callback(null, 10, 20);
    },
    function(arg1, arg2, callback) {
        var sum = arg1 + arg2; //30
        callback(null, sum);
    },
    function(arg1, callback) {
        var final = arg1 * 2; //60
        callback(null, final);
    }
],
function (err, response) {
    // response = 60
});

More info

  • Callbacks first argument must be an error (which can be null) and any further arguments will be considerate as the resultant value.
  • If a callback returns a error the final callback will be fired immediately.

Notes

  • microasync has nothing to do with Async project, it has a totally different implementation.

License

MIT