I have this snippet working fine using async.applyEachSeries
.
var async = require("async");
function firstThing(state, next) {
state.firstThingDone = true;
setImmediate(next);
}
function secondThing(state, next) {
state.secondThingDone = true;
setImmediate(next);
}
var state = {};
async.applyEachSeries([
firstThing,
secondThing
], state, function (error) {
console.log(error, state);
});
I have made several attempts to convert it to highland.js but I'm not grokking the plumbing there. I'm pretty sure I need to do _.wrapCallback(firstThing)
for both firstThing and secondThing but not sure whether I need _.pipeline
or .series()
or what.
There isn't a nice 1:1 translation at the moment, since Highland lacks an 'applyEach', but by changing (or wrapping) the firstThing and lastThing functions you might get a nice enough result: