This is a simple JS-based queue system.
// create a new queue
var queue = new Queue();
// enqueue an item
queue.enqueue('item');
// dequeue an item
var item = queue.dequeue();
// get the item at the front of the queue but do not dequeue it.
var item = queue.peek();
// determine the number of items in the queue
var length = queue.getLength();
// determine whether the queue is empty
var isEmpty = queue.isEmpty();
Usage:
// loop through the queue and get each item..
while( !queue.isEmpty() ){
// remove the item from the queue and process...
var item = queue.dequeue();
console.log( item );
}