Closed robogeek closed 3 years ago
This is using the Promise version of fastq. In that version, the push method returns a Promise. Therefore pushing the Promise's into an array lets us use Promise.all to know when all tasks have been completed.
Does this look correct?
Yes
Your documentation didn't help me understand how to use the
drain
function to wait until the queue is fully processed.What I came up with is:
This is using the Promise version of
fastq
. In that version, thepush
method returns a Promise. Therefore pushing the Promise's into an array lets us use Promise.all to know when all tasks have been completed.Does this look correct?
An alternative I've coded but haven't tested is:
It seems from your test scripts that one simply assigns a function to the
drain
field, and it'll automatically be called. Therefore one way to wait for this function to be called is this Promise here.Is either preferable over the other?