MCPcopy
hub / github.com/nodejs/undici / assertCacheMethods

Function assertCacheMethods

lib/util/cache.js:359–373  ·  view source on GitHub ↗

* @param {unknown} methods * @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]}

(methods, name = 'CacheMethods')

Source from the content-addressed store, hash-verified

357 * @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]}
358 */
359function assertCacheMethods (methods, name = 'CacheMethods') {
360 if (!Array.isArray(methods)) {
361 throw new TypeError(`expected type of ${name} needs to be an array, got ${methods === null ? 'null' : typeof methods}`)
362 }
363
364 if (methods.length === 0) {
365 throw new TypeError(`${name} needs to have at least one method`)
366 }
367
368 for (const method of methods) {
369 if (!safeHTTPMethods.includes(method)) {
370 throw new TypeError(`element of ${name}-array needs to be one of following values: ${safeHTTPMethods.join(', ')}, got ${method}`)
371 }
372 }
373}
374
375/**
376 * Creates a string key for request deduplication purposes.

Callers 1

cache.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…