I need to create a blocking queue in Javascript. There are pop() and shift() methods in Array.prototype, but the description says:
Return value: The last element from the array;
undefinedif the array is empty.
I need a method which does not return undefined, but waits until there is some element to return.
The purpose is, that my code is driven by multiple asynchronous operations which pushes elements to the queue and I need to process them.
async.queue().