(key, value)
| 31 | } |
| 32 | |
| 33 | put(key, value) { |
| 34 | const hasKey = this.get(key) !== -1; |
| 35 | const isAtCapacity = this.map.size === this.capacity; |
| 36 | |
| 37 | if (hasKey) return (this.tail.prev.value = value); |
| 38 | if (isAtCapacity) this.removeLastUsed(); |
| 39 | |
| 40 | const node = { key, value }; |
| 41 | this.map.set(key, node); |
| 42 | this.moveToFront(node); |
| 43 | } |
| 44 | |
| 45 | moveToFront(node) { |
| 46 | const [prev, next] = [this.tail.prev, this.tail]; |
nothing calls this directly
no test coverage detected