MCPcopy Create free account
hub / github.com/nodejs/undici / assertCacheValue

Function assertCacheValue

lib/util/cache.js:279–305  ·  view source on GitHub ↗

* @param {any} value

(value)

Source from the content-addressed store, hash-verified

277 * @param {any} value
278 */
279function assertCacheValue (value) {
280 if (typeof value !== 'object') {
281 throw new TypeError(`expected value to be object, got ${typeof value}`)
282 }
283
284 for (const property of ['statusCode', 'cachedAt', 'staleAt', 'deleteAt']) {
285 if (typeof value[property] !== 'number') {
286 throw new TypeError(`expected value.${property} to be number, got ${typeof value[property]}`)
287 }
288 }
289
290 if (typeof value.statusMessage !== 'string') {
291 throw new TypeError(`expected value.statusMessage to be string, got ${typeof value.statusMessage}`)
292 }
293
294 if (value.headers != null && typeof value.headers !== 'object') {
295 throw new TypeError(`expected value.rawHeaders to be object, got ${typeof value.headers}`)
296 }
297
298 if (value.vary !== undefined && typeof value.vary !== 'object') {
299 throw new TypeError(`expected value.vary to be object, got ${typeof value.vary}`)
300 }
301
302 if (value.etag !== undefined && typeof value.etag !== 'string') {
303 throw new TypeError(`expected value.etag to be string, got ${typeof value.etag}`)
304 }
305}
306
307/**
308 * @see https://www.rfc-editor.org/rfc/rfc9111.html#name-cache-control

Callers 2

createWriteStreamMethod · 0.85
createWriteStreamMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected