MCPcopy Create free account
hub / github.com/nodejs/node / delete

Method delete

deps/undici/src/lib/web/cache/cache.js:390–448  ·  view source on GitHub ↗
(request, options = {})

Source from the content-addressed store, hash-verified

388 }
389
390 async delete (request, options = {}) {
391 webidl.brandCheck(this, Cache)
392
393 const prefix = 'Cache.delete'
394 webidl.argumentLengthCheck(arguments, 1, prefix)
395
396 request = webidl.converters.RequestInfo(request)
397 options = webidl.converters.CacheQueryOptions(options, prefix, 'options')
398
399 /**
400 * @type {Request}
401 */
402 let r = null
403
404 if (webidl.is.Request(request)) {
405 r = getRequestState(request)
406
407 if (r.method !== 'GET' && !options.ignoreMethod) {
408 return false
409 }
410 } else {
411 assert(typeof request === 'string')
412
413 r = getRequestState(new Request(request))
414 }
415
416 /** @type {CacheBatchOperation[]} */
417 const operations = []
418
419 /** @type {CacheBatchOperation} */
420 const operation = {
421 type: 'delete',
422 request: r,
423 options
424 }
425
426 operations.push(operation)
427
428 const cacheJobPromise = Promise.withResolvers()
429
430 let errorData = null
431 let requestResponses
432
433 try {
434 requestResponses = this.#batchCacheOperations(operations)
435 } catch (e) {
436 errorData = e
437 }
438
439 queueMicrotask(() => {
440 if (errorData === null) {
441 cacheJobPromise.resolve(!!requestResponses?.length)
442 } else {
443 cacheJobPromise.reject(errorData)
444 }
445 })
446
447 return cacheJobPromise.promise

Callers

nothing calls this directly

Calls 9

#batchCacheOperationsMethod · 0.95
queueMicrotaskFunction · 0.85
brandCheckMethod · 0.80
argumentLengthCheckMethod · 0.80
RequestInfoMethod · 0.80
rejectMethod · 0.80
assertFunction · 0.50
pushMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected