function-flow
v2.0.0
Published
Asynchronous sequence/parallel flow.
Downloads
9
Readme
function-flow
Enables asynchronous sequence/parallel execution flow.
API
Function.async(...operations)
Function.asyncMap(array, [functor], callback)
Basic Usage
// sequence
Function.async(
(next) => {
next(null, 1)
},
(num, next) => {
setTimeout(()=>{next(null, num+1)}, 100);
},
(num, next) => {
setTimeout(()=>{next(null, num+1)}, 100);
},
(err, result) => {
result.should.be.equal(3)
}
);
Function.asyncMap(
[1,2,3]
,
(item, next) => {
setTimeout(()=>{next(null, item+1)}, 100);
}
,
(err, results) => {
results[2].should.be.equal(4);
}
);
See also Tests for more samples.
Repo
[https://github.com/alitskevich/function-async]
Legal
The MIT License (MIT)
Copyright (c) 2015 Alex Litskevich