* @param {unknown} methods * @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]}
(methods, name = 'CacheMethods')
| 696 | * @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]} |
| 697 | */ |
| 698 | function assertCacheMethods (methods, name = 'CacheMethods') { |
| 699 | if (!Array.isArray(methods)) { |
| 700 | throw new TypeError(`expected type of ${name} needs to be an array, got ${methods === null ? 'null' : typeof methods}`) |
| 701 | } |
| 702 | |
| 703 | if (methods.length === 0) { |
| 704 | throw new TypeError(`${name} needs to have at least one method`) |
| 705 | } |
| 706 | |
| 707 | for (const method of methods) { |
| 708 | if (!arrayIncludes(safeHTTPMethods, method)) { |
| 709 | throw new TypeError(`element of ${name}-array needs to be one of following values: ${safeHTTPMethods.join(', ')}, got ${method}`) |
| 710 | } |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * Creates a string key for request deduplication purposes. |