UNPKG

@maximai/maxim-js

Version:

Maxim AI JS SDK. Visit https://getmaxim.ai for more info.

34 lines 880 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Queue = void 0; class Queue { constructor(maxSize = 10000) { this.storage = new Array(); this.maxSize = maxSize; } enqueue(item) { if (this.storage.length >= this.maxSize) { this.storage.shift(); } this.storage.push(item); } enqueueAll(items) { if (this.storage.length + items.length > this.maxSize) { this.storage.splice(0, items.length - this.maxSize); } this.storage.push(...items); } dequeue() { return this.storage.shift(); } dequeueAll() { const items = this.storage; this.storage = new Array(); return items; } get size() { return this.storage.length; } } exports.Queue = Queue; //# sourceMappingURL=queue.js.map