MCPcopy Create free account
hub / github.com/denoland/std / #pruneToMaxSize

Method #pruneToMaxSize

cache/lru_cache.ts:152–165  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150 }
151
152 #pruneToMaxSize(): void {
153 if (this.size <= this.#maxSize) return;
154 const key = this.keys().next().value!;
155 const value = super.get(key)!;
156 super.delete(key);
157 if (this.#eject) {
158 this.#ejecting = true;
159 try {
160 this.#eject(key, value, "evicted");
161 } finally {
162 this.#ejecting = false;
163 }
164 }
165 }
166
167 /**
168 * Checks whether an element with the specified key exists or not. Does

Callers 1

setMethod · 0.95

Calls 4

keysMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected