* Helper function to convert a response body to a string.
( body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[], )
| 211 | * Helper function to convert a response body to a string. |
| 212 | */ |
| 213 | function _toTextBody( |
| 214 | body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[], |
| 215 | ): string { |
| 216 | if (typeof body === 'string') { |
| 217 | return body; |
| 218 | } |
| 219 | if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) { |
| 220 | throw new Error('Automatic conversion to text is not supported for ArrayBuffers.'); |
| 221 | } |
| 222 | if (typeof Blob !== 'undefined' && body instanceof Blob) { |
| 223 | throw new Error('Automatic conversion to text is not supported for Blobs.'); |
| 224 | } |
| 225 | return JSON.stringify(_toJsonBody(body, 'text')); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Convert a response body to the requested type. |
no test coverage detected
searching dependent graphs…