MCPcopy Create free account
hub / github.com/denoland/std / delete

Method delete

cache/lru_cache.ts:296–315  ·  view source on GitHub ↗

* Deletes the value associated with the given key. * * @experimental **UNSTABLE**: New API, yet to be vetted. * * @param key The key to delete. * @returns `true` if the key was deleted, `false` otherwise. * * @example Deleting a key from the cache * ```ts * import { LruCac

(key: K)

Source from the content-addressed store, hash-verified

294 * ```
295 */
296 override delete(key: K): boolean {
297 if (this.#ejecting) {
298 throw new TypeError(
299 "Cannot delete entry in LruCache: cache is not re-entrant during onEject callbacks",
300 );
301 }
302 const value = super.get(key);
303 const existed = super.delete(key);
304 if (!existed) return false;
305
306 if (this.#eject) {
307 this.#ejecting = true;
308 try {
309 this.#eject(key, value!, "deleted");
310 } finally {
311 this.#ejecting = false;
312 }
313 }
314 return true;
315 }
316
317 /**
318 * Clears the cache.

Callers

nothing calls this directly

Calls 2

getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected