queuejs

a simple queue data structure

queue.js

A simple queue data structure for Node.js and the browser.

As component for the browser:

$ component install janogonzalez/queuejs

As npm for Node.js:

$ npm install queuejs
var Queue = require('queuejs');
 
var queue = new Queue();
 
queue.enq(10);
queue.size(); // 1 
queue.peek(); // 10 
queue.deq(); // 10 

Initializes a new empty Queue.

Dequeues the top element of the Queue. Throws an Error when the queue is empty.

Returns whether the Queue is empty or not.

Enqueues the element at the end of the Queue and returns its new size.

Peeks at the top element of the Queue. Throws an Error when the queue is empty.

Returns the size of the Queue.

$ npm test

MIT