4 ms·
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 sty
by _Marak_ 9y ago
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 http://caolan.github.io/async/docs.html#eachLimit
https://github.com/tc39/proposal-async-iteration https://github.com/tc39/proposal-async-iteration