node-red-contrib-self-healing
Version:
SHEN: Self-healing extensions for Node-RED.
36 lines (27 loc) • 477 B
JavaScript
/**
* Implementation of a regular queue.
*/
class Queue {
constructor() {
this.elements = [];
}
push(element) {
this.elements.push(element);
}
dequeue() {
return this.elements.shift();
}
isEmpty() {
return this.elements.length == 0;
}
getLength() {
return this.elements.length;
}
getElements() {
return this.elements;
}
peek() {
return this.isEmpty() ? undefined : this.elements[0];
}
}
module.exports = Queue;