* @param {unknown} methods * @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]}
(methods, name = 'CacheMethods')
| 656 | * @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]} |
| 657 | */ |
| 658 | function assertCacheMethods (methods, name = 'CacheMethods') { |
| 659 | if (!Array.isArray(methods)) { |
| 660 | throw new TypeError(`expected type of ${name} needs to be an array, got ${methods === null ? 'null' : typeof methods}`) |
| 661 | } |
| 662 | |
| 663 | if (methods.length === 0) { |
| 664 | throw new TypeError(`${name} needs to have at least one method`) |
| 665 | } |
| 666 | |
| 667 | for (const method of methods) { |
| 668 | if (!arrayIncludes(safeHTTPMethods, method)) { |
| 669 | throw new TypeError(`element of ${name}-array needs to be one of following values: ${safeHTTPMethods.join(', ')}, got ${method}`) |
| 670 | } |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | /** |
| 675 | * Creates a string key for request deduplication purposes. |