MCPcopy Index your code
hub / github.com/angular/angular / _toTextBody

Function _toTextBody

packages/common/http/testing/src/request.ts:213–226  ·  view source on GitHub ↗

* Helper function to convert a response body to a string.

(
  body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[],
)

Source from the content-addressed store, hash-verified

211 * Helper function to convert a response body to a string.
212 */
213function _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.

Callers 1

_maybeConvertBodyFunction · 0.85

Calls 1

_toJsonBodyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…