Skip to content

Commit

Permalink
Better names for internal classes/structs
Browse files Browse the repository at this point in the history
  • Loading branch information
HDegroote committed Jul 3, 2024
1 parent 576ebca commit 7fa22e6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
class Entry {
class CacheEntry {
constructor (key, index, map) {
this.key = key
this.index = index
this.map = map
}
}

class CacheValue {
constructor (entry, value) {
this.entry = entry
this.value = value
}
}

class GlobalCache {
constructor ({ maxSize = 65536, parent = null } = {}) {
this.maxSize = parent?.maxSize || maxSize
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7fa22e6

Please sign in to comment.