al6x / synchronize

Write asynchronous code as if it's synchronous
http://alexeypetrushin.github.com/synchronize
316 stars 57 forks source link

await and defer destroys any for loop #45

Open neimanpinchas opened 8 years ago

neimanpinchas commented 8 years ago
var array=['sun','mon','tue']
sync.fiber(
function(){
for (i=0;i<array.length;i++)
{
console.log(sync.await(readFile(array[i],'utf8',sync.defer()))) //does only sunday
}
var i=0
while (i<array.length)
{
console.log(sync.await(readFile(array[i],'utf8',sync.defer()))) //does all days
i++
}
})
d3m3vilurr commented 8 years ago

I was tested this with same code(just one diff, I was used real fs.readFile), but cannot reproduce. is this issue real??