MCPcopy
hub / github.com/TheAlgorithms/JavaScript / get

Method get

Cache/LRUCache.js:90–106  ·  view source on GitHub ↗

* @param {string} key * @returns {*}

(key)

Source from the content-addressed store, hash-verified

88 * @returns {*}
89 */
90 get(key) {
91 key = String(key)
92 // Returns the value for the input key. Returns null if key is not present in cache
93 if (this.cache.has(key)) {
94 const value = this.cache.get(key)
95
96 // refresh the cache to update the order of key
97 this.cache.delete(key)
98 this.cache.set(key, value)
99
100 this.hits++
101 return value
102 }
103
104 this.misses++
105 return null
106 }
107
108 /**
109 * @param {JSON} json

Callers 15

memoizeFunction · 0.45
LFUCache.test.jsFile · 0.45
fibonacciCacheFunction · 0.45
LRUCache.test.jsFile · 0.45
dfsDepthMethod · 0.45
getLCAMethod · 0.45
addEdgeMethod · 0.45
dfsMethod · 0.45
kthAncestorMethod · 0.45
caesarCipherFunction · 0.45
FibonacciRecursiveDPFunction · 0.45
TwoSumFunction · 0.45

Calls 3

hasMethod · 0.45
deleteMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected