* @method get * @description - This method return the value of key & refresh the frequencyMap by the oldNode * @param {string} key * @returns {any}
(key)
| 148 | * @returns {any} |
| 149 | */ |
| 150 | get(key) { |
| 151 | key = String(key) // converted to string |
| 152 | |
| 153 | if (this.cache.has(key)) { |
| 154 | const oldNode = this.cache.get(key) |
| 155 | this.#frequencyMap.refresh(oldNode) |
| 156 | |
| 157 | this.hits++ |
| 158 | |
| 159 | return oldNode.value |
| 160 | } |
| 161 | |
| 162 | this.misses++ |
| 163 | return null |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * @method set |
no test coverage detected