diff --git a/index.js b/index.js index 7757727..55eae8f 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -class Entry { +class CacheEntry { constructor (key, index, map) { this.key = key this.index = index @@ -6,6 +6,13 @@ class Entry { } } +class CacheValue { + constructor (entry, value) { + this.entry = entry + this.value = value + } +} + class GlobalCache { constructor ({ maxSize = 65536, parent = null } = {}) { this.maxSize = parent?.maxSize || maxSize @@ -35,9 +42,10 @@ class GlobalCache { if (this._array.length >= this.maxSize) this._gc() - const entry = new Entry(key, this._array.length, this._map) + const entry = new CacheEntry(key, this._array.length, this._map) this._array.push(entry) - this._map.set(key, { entry, value }) + const cacheValue = new CacheValue(entry, value) + this._map.set(key, cacheValue) } delete (key) {