* @param {any} value
(value)
| 87 | * @param {any} value |
| 88 | */ |
| 89 | function 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 |
no outgoing calls
no test coverage detected
searching dependent graphs…