(body: RequestInit['body'] | ReadableStream | null | undefined)
| 450 | } |
| 451 | |
| 452 | function getBodyForFetchCacheKey(body: RequestInit['body'] | ReadableStream | null | undefined) { |
| 453 | if (body == null) { |
| 454 | return { cacheable: true, identity: undefined }; |
| 455 | } |
| 456 | |
| 457 | if (typeof body === 'string') { |
| 458 | return { |
| 459 | cacheable: true, |
| 460 | identity: { type: 'string', value: getBodyStringForFetchCacheKey(body) }, |
| 461 | }; |
| 462 | } |
| 463 | |
| 464 | if (typeof URLSearchParams !== 'undefined' && body instanceof URLSearchParams) { |
| 465 | return { |
| 466 | cacheable: true, |
| 467 | identity: { type: 'url-search-params', value: getSearchParamsForFetchCacheKey(body) }, |
| 468 | }; |
| 469 | } |
| 470 | |
| 471 | if (body instanceof ArrayBuffer) { |
| 472 | return { cacheable: true, identity: { type: 'array-buffer', ...hashBytesForCacheKey(body) } }; |
| 473 | } |
| 474 | |
| 475 | if (ArrayBuffer.isView(body)) { |
| 476 | return { |
| 477 | cacheable: true, |
| 478 | identity: { type: body.constructor.name, ...hashBytesForCacheKey(body) }, |
| 479 | }; |
| 480 | } |
| 481 | |
| 482 | return { cacheable: false, identity: undefined }; |
| 483 | } |
| 484 | |
| 485 | function getOptionsForFetchCacheKey(options: RequestInit, bodyIdentity: unknown) { |
| 486 | const identity: Record<string, unknown> = {}; |
no test coverage detected
searching dependent graphs…