UNPKG

@gecut/utilities

Version:

The ultimate utility toolkit from Gecut Company, crafted with TypeScript for optimal speed and efficiency. Designed to boost productivity with a suite of fast and optimized tools.

34 lines 831 B
export class InMemorySimpleCache { constructor(maxSize) { this.memory = new Map(); this.maxSize = -1; if (maxSize && maxSize > 0) { this.maxSize = maxSize; } } get(key) { return this.memory.get(key); } set(key, value) { this.memory.set(key, value); if (this.maxSize > 0 && this.size >= this.maxSize) { const firstKey = this.memory.keys().next(); if (!firstKey.done) { this.delete(firstKey.value); } } } delete(key) { return this.memory.delete(key); } clearAll() { this.memory.clear(); } has(key) { return this.memory.has(key); } get size() { return this.memory.size; } } //# sourceMappingURL=in-memory.simple.js.map