I want to make non-blocking loop over array with objects, so I used async.each function:
log.info("before");
async.each(products , function(prdt, callback){
for(var i = 0 ; i <4000000000; i++){
var s = i;
}
console.log("inside");
callback();
}, function (err) {
console.log("end");
});
log.info("after");
So if I run code above I have a such messages output:
before
inside
....
inside
end
after
If async.each asynchoronous why I dont see output in that order?
before
after
inside
inside..
end
UPDATE1: thx for answers, but If I want to execute that code inside my router, I will blocked all responces to my server? What I need to change?