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

Function assertCacheValue

lib/util/cache.js:89–115  ·  view source on GitHub ↗

* @param {any} value

(value)

Source from the content-addressed store, hash-verified

87 * @param {any} value
88 */
89function assertCacheValue (value) {
90 if (typeof value !== 'object') {
91 throw new TypeError(`expected value to be object, got ${typeof value}`)
92 }
93
94 for (const property of ['statusCode', 'cachedAt', 'staleAt', 'deleteAt']) {
95 if (typeof value[property] !== 'number') {
96 throw new TypeError(`expected value.${property} to be number, got ${typeof value[property]}`)
97 }
98 }
99
100 if (typeof value.statusMessage !== 'string') {
101 throw new TypeError(`expected value.statusMessage to be string, got ${typeof value.statusMessage}`)
102 }
103
104 if (value.headers != null && typeof value.headers !== 'object') {
105 throw new TypeError(`expected value.rawHeaders to be object, got ${typeof value.headers}`)
106 }
107
108 if (value.vary !== undefined && typeof value.vary !== 'object') {
109 throw new TypeError(`expected value.vary to be object, got ${typeof value.vary}`)
110 }
111
112 if (value.etag !== undefined && typeof value.etag !== 'string') {
113 throw new TypeError(`expected value.etag to be string, got ${typeof value.etag}`)
114 }
115}
116
117/**
118 * @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

Used in the wild real call sites across dependent graphs

searching dependent graphs…