* @param {any} value
(value)
| 277 | * @param {any} value |
| 278 | */ |
| 279 | function 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 |
no outgoing calls
no test coverage detected