Monday, 15 April 2013

javascript - Making a synchronous loop from synchronous callbacks with node.js + async module -



javascript - Making a synchronous loop from synchronous callbacks with node.js + async module -

the popular node.js module async includes functions collections , command flow which, versions of can operate in parallel or in series.

but among them cannot find way build loop operates in series.

i'm trying same pseudocode:

forever { l = getline(); if (l === undefined) { break; } else { dostuff(l); } } if wanted calls getline() called in parallel utilize async.whilst. if wanted iterate on array rather create for or while loop utilize async.eachseries.

what can utilize series behaviour in command flow rather collection iteration?

async.whilst does execute function serially need, can this:

var l = getline(); async.whilst( function () { homecoming l !== undefined; }, function (callback) { dostuff(l); l = getline(); callback(); // check function isn't called 1 time again until callback called }, function (err) { // done } );

javascript node.js loops async.js node-async

No comments:

Post a Comment