* @param {any} value
(value)
| 317 | * @param {any} value |
| 318 | */ |
| 319 | function assertCacheValue (value) { |
| 320 | if (typeof value !== 'object') { |
| 321 | throw new TypeError(`expected value to be object, got ${typeof value}`) |
| 322 | } |
| 323 | |
| 324 | for (const property of ['statusCode', 'cachedAt', 'staleAt', 'deleteAt']) { |
| 325 | if (typeof value[property] !== 'number') { |
| 326 | throw new TypeError(`expected value.${property} to be number, got ${typeof value[property]}`) |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | if (typeof value.statusMessage !== 'string') { |
| 331 | throw new TypeError(`expected value.statusMessage to be string, got ${typeof value.statusMessage}`) |
| 332 | } |
| 333 | |
| 334 | if (value.headers != null && typeof value.headers !== 'object') { |
| 335 | throw new TypeError(`expected value.rawHeaders to be object, got ${typeof value.headers}`) |
| 336 | } |
| 337 | |
| 338 | if (value.vary !== undefined && typeof value.vary !== 'object') { |
| 339 | throw new TypeError(`expected value.vary to be object, got ${typeof value.vary}`) |
| 340 | } |
| 341 | |
| 342 | if (value.etag !== undefined && typeof value.etag !== 'string') { |
| 343 | throw new TypeError(`expected value.etag to be string, got ${typeof value.etag}`) |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * @see https://www.rfc-editor.org/rfc/rfc9111.html#name-cache-control |
no outgoing calls
no test coverage detected