* Convert a response body to the requested type.
( responseType: string, body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[] | null, )
| 229 | * Convert a response body to the requested type. |
| 230 | */ |
| 231 | function _maybeConvertBody( |
| 232 | responseType: string, |
| 233 | body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[] | null, |
| 234 | ): ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[] | null { |
| 235 | if (body === null) { |
| 236 | return null; |
| 237 | } |
| 238 | switch (responseType) { |
| 239 | case 'arraybuffer': |
| 240 | return _toArrayBufferBody(body); |
| 241 | case 'blob': |
| 242 | return _toBlob(body); |
| 243 | case 'json': |
| 244 | return _toJsonBody(body); |
| 245 | case 'text': |
| 246 | return _toTextBody(body); |
| 247 | default: |
| 248 | throw new Error(`Unsupported responseType: ${responseType}`); |
| 249 | } |
| 250 | } |
no test coverage detected
searching dependent graphs…