queuerr
v0.1.0
Published
Library with a simple queue
Downloads
2
Readme
queuer.js
This library include a simple queue
Methods
/**
* Initialize the queue
*
* @param {Array|null} array
* @returns {Queuer|undefined}
*/
initialize(array);
/**
* Check if the queue is empty
*
* @returns {boolean}
*/
isEmpty();
/**
* Push an element at the end of the queue
*
* @param {Object} element
* @returns {Queuer|undefined}
*/
enqueue(element);
/**
* Get the first element of the queue
*
* @returns {Object|undefined}
*/
dequeue();
/**
* Get queue length
*
* @returns {number}
*/
length();
/**
* Delete all objects
*
* @returns {boolean}
*/
clear();
/**
* Get queue as array
*
* @returns {Array}
*/
toArray();
/**
* Get queue as string
*
* @returns {String}
*/
toString();
Example
const { Queuer } = require('./queuer');
let queuer = new Queuer();
queuer.enqueue(1);
queuer.enqueue(2);
queuer.enqueue(3);
queuer.enqueue(4);
queuer.enqueue(5);
queuer.dequeue(); // 1
queuer.toString(); // 2,3,4,5
queuer.isEmpty(); // false
queuer.length(); // 4
queuer.toArray(); // [2, 3, 4, 5]
for (let item of queuer) {
item;
}