UNPKG

ps2census

Version:

Client to connect to the PS2 Event Stream websocket.

31 lines 916 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DecayingSet = void 0; class DecayingSet { constructor(partitions, decay) { this.partitions = partitions; this.index = 0; this.set = []; for (let i = 0; i < partitions; i++) this.set.push(new Set()); this.timeout = setInterval(() => { this.index++; if (this.index == this.partitions) this.index = 0; this.set[this.index].clear(); }, decay / partitions); this.timeout.unref && this.timeout.unref(); } add(value) { this.set[this.index].add(value); return this; } clear() { this.set.forEach(set => set.clear()); } has(value) { return this.set.some(set => set.has(value)); } } exports.DecayingSet = DecayingSet; //# sourceMappingURL=decaying-set.js.map