MCPcopy Create free account
hub / github.com/chakra-ui/panda / getOrInsert

Method getOrInsert

packages/shared/src/cache-map.ts:84–91  ·  view source on GitHub ↗
(key: K, defaultValue: V)

Source from the content-addressed store, hash-verified

82 }
83
84 getOrInsert(key: K, defaultValue: V): V {
85 if (this.cache.has(key)) {
86 this.updateKeyUsage(key)
87 return this.cache.get(key)!
88 }
89 this.set(key, defaultValue)
90 return defaultValue
91 }
92
93 getOrInsertComputed(key: K, callback: (key: K) => V): V {
94 if (this.cache.has(key)) {

Callers

nothing calls this directly

Calls 4

updateKeyUsageMethod · 0.95
setMethod · 0.95
hasMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected