GithubHelp home page GithubHelp logo

async-all's Introduction

Build Status

Run a bunch of asynchronous functions and get all the values at once at the end!

var all = require('./')

function someAsyncThing(cb) {
	setTimeout(function() {
		cb(null, 'some sweet value')
	}, 50)
}

function someOtherAsyncThing(cb) {
	setTimeout(function() {
		cb(null, 'some other value')
	}, 10)
}

all({
	someValue: someAsyncThing,
	whatever: someOtherAsyncThing
}, function(err, results) {
	results.someValue // => 'some sweet value'
	results.whatever // => 'some other value'
})

all({
	tmp: fs.stat.bind(fs, '/tmp'),
	broken: fs.stat.bind(fs, '/tmp/doesntexist/asfarasIknow')
}, function(err, results) {
	startsWith(err.message, 'ENOENT') // => true
})

Install

npm install async-all

Run the tests

git clone https://github.com/TehShrike/async-all.git
cd async-all
npm test

License

WTFPL

async-all's People

Contributors

tehshrike avatar

Watchers

 avatar  avatar  avatar

async-all's Issues

Calling async-all with null

I'm not sure how you want this handled, but it's not caught because typeof null === object.

> var all = require('async-all')
undefined
> all(null, console.log)
TypeError: Object.keys called on non-object
    at Function.keys (native)
    at all (C:\Users\Michael\Github\JS_Source\node_modules\async-all\index.js:37:9)
    at repl:1:18
    at REPLServer.defaultEval (repl.js:132:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:279:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:214:10)
    at REPLServer.Interface._line (readline.js:553:8)
>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.