MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / parse

Method parse

Cache/LFUCache.js:209–221  ·  view source on GitHub ↗

* @method parse * @description - This method receive a valid LFUCache JSON & run JSON.prase() method and merge with existing LFUCache * @param {JSON} json * @returns {LFUCache} - merged

(json)

Source from the content-addressed store, hash-verified

207 * @returns {LFUCache} - merged
208 */
209 parse(json) {
210 const { misses, hits, cache } = JSON.parse(json)
211
212 this.misses += misses ?? 0
213 this.hits += hits ?? 0
214
215 for (const key in cache) {
216 const { value, frequency } = cache[key]
217 this.set(key, value, frequency)
218 }
219
220 return this
221 }
222
223 /**
224 * @method clear

Callers

nothing calls this directly

Calls 1

setMethod · 0.95

Tested by

no test coverage detected