Software version
metasync: 0.3.26
Node: 8.11.3
NPM: 5.6.0
When the first item of an array of composed functions is a double brackets array (parallel executed), the next functions in the chain of a composition isn't called.
For example, the next code ...
const metasync = require('metasync')
function stubFunc (data, cb) {
cb(null, data)
}
function fn1 (data, cb) {
setTimeout(() => {
console.log(`fn1 has been processed (data: ${data})`)
cb(null, 1)
}, 300)
}
function fn2 (data, cb) {
setTimeout(() => {
console.log(`fn2 has been processed (data: ${data})`)
cb(null, 2)
}, 300)
}
function fn3 (data, cb) {
setTimeout(() => {
console.log(`fn3 has been processed (data: ${data})`)
cb(null, 3)
}, 200)
}
function fn4 (data, cb) {
setTimeout(() => {
console.log(`fn4 has been processed (data: ${data})`)
cb(null, 4)
}, 300)
}
const fc = metasync([[[fn1, fn2]], fn3, fn4])
fc([0], (err, data) => {
if (err) {
console.log(err.message, 'data:', data)
} else {
console.log('Process finished. data:', data)
}
})
...outputs
fn1 has been processed (data: 0)
fn2 has been processed (data: 0,1)
Process finished. data: [ 0, 1, 2 ]
Though, if I insert any function in the chain before the parallel group...
const fc = metasync([stubFunc, [[fn1, fn2]], fn3, fn4])
... then all function are called.
fn1 has been processed (data: 0)
fn2 has been processed (data: 0,1)
fn3 has been processed (data: 0,1,2)
fn4 has been processed (data: 0,1,2,3)
Process finished. data: [ 0, 1, 2, 3, 4 ]
Software version metasync: 0.3.26 Node: 8.11.3 NPM: 5.6.0
When the first item of an array of composed functions is a double brackets array (parallel executed), the next functions in the chain of a composition isn't called.
For example, the next code ...
...outputs
Though, if I insert any function in the chain before the parallel group...
... then all function are called.