websocket-ts
Version:
<div> <div align="center"> <img src="https://raw.githubusercontent.com/jjxxs/websocket-ts/gh-pages/websocket-ts-logo.svg" alt="websocket-ts" width="300" height="65" /> </div> <p align="center"> <img src="https://github.com/jjxxs/websocket-ts
36 lines • 1.13 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrayQueue = void 0;
/**
* An array queue is a queue that has an unbounded capacity. Reading from an array queue
* will return the oldest element and effectively remove it from the queue.
*/
var ArrayQueue = /** @class */ (function () {
function ArrayQueue() {
this.elements = [];
}
ArrayQueue.prototype.add = function (element) {
this.elements.push(element);
};
ArrayQueue.prototype.clear = function () {
this.elements.length = 0;
};
ArrayQueue.prototype.forEach = function (fn) {
this.elements.forEach(fn);
};
ArrayQueue.prototype.length = function () {
return this.elements.length;
};
ArrayQueue.prototype.isEmpty = function () {
return this.elements.length === 0;
};
ArrayQueue.prototype.peek = function () {
return this.elements[0];
};
ArrayQueue.prototype.read = function () {
return this.elements.shift();
};
return ArrayQueue;
}());
exports.ArrayQueue = ArrayQueue;
//# sourceMappingURL=array_queue.js.map
;