2.1.1 • Published 10 years ago

wait-for v2.1.1

Weekly downloads
41
License
ISC
Repository
github
Last release
10 years ago

wait-for

Tiny callback counting module to run a function when all watched functions have completed

Usage

set up what you want to do after async things have happened:

var after = waitFor(done);

Wait for things:

fs.readFile('bla', after(function(){
    ...

    fs.readFile('blee', after(function(){
        ...
    });
});

done will only be called after all wrapped async calls are complete.

If any task errors, no other tasks will be called, but those in flight will call back. The error will be passed to done:

function done(error){
    // called if any error occurs, or if all tasks succeded
});

You can specify that the fn will not error (or you don't care if if does) by passing true as the first parameter:

after(true, function(){...})
2.1.1

10 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.0.0

10 years ago