Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 754 Bytes

README.md

File metadata and controls

30 lines (23 loc) · 754 Bytes

ParallelJS

Execute asynchronous js functions in parallel and get their results in a common callback function.

##Usage

executeAsync([func1, func2, func3], function (res) {
    console.log(res);
    res[0];  //result of func1
    res[1];  //result of func2
});

Where func1, func2, func3 are your asyncronous functions. Such as:

function func1(cb) {
    setTimeout(function () {
        cb("func1");
    },300)
}
function func2(cb) {
    setTimeout(function () {
        cb("func2");
    },200)
}
function func3(cb) {
    cb({ data : "data", foo: "foo"})
}

####Note: Not to be confused with https://parallel.js.org/, a far more advanced library for way more complex problems