News for hackers. Stuff that matters.
Re:Let’s make a JavaScript Wait function by _Marak_ on Sunday November 12, 2017 @02:59PM (#15682332)
The callback style pseudo code they posted as an example is not a good example of callback style JavaScript code.

The first code posted is showing callback style with a nested loop over a directory listing to perform an image resize using graphics magick. Aside from the fact the author isn't actually calling any callbacks to indicate a complete event ( and won't be able to unless they have an async iterator ), there is a concurrency problem with usage of gm.

You really actually want to a run something like an async eachLimit in order to set the amount of open GM instances running concurrently or run the risk of running out of memory / cpu.

The second example using async/await doesn't mention anything about using async iterators either.

see:

http://caolan.github.io/async/docs.html#eachLimit

https://github.com/tc39/proposal-async-iteration

There are no comments on this comment yet.