should this code return 12334 or 12433 ?
I expect 12334 but it gives 12433...
console.log '1' anArray.forEach (info, index, array)-> console.log '2' await model.findOne info, defer(err, doc) console.log '3' console.log '4'
Your intuition is incorrect: IcedCoffeeScript's
await...defer cannot block a synchronous
forEach on an array, you've committed to iterating through that entire array before any events can fire.
The good news is that you can get the behavior you want by using IcedCoffeeScript's own loop constructs. In your case,
for info, index in anArray -> ...
There is currently no discussion for this recipe.
This recipe can be found in it's original form on Stack Over Flow.