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

Function _maybeConvertBody

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

* Convert a response body to the requested type.

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

Source from the content-addressed store, hash-verified

229 * Convert a response body to the requested type.
230 */
231function _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}

Callers 1

flushMethod · 0.85

Calls 4

_toArrayBufferBodyFunction · 0.85
_toBlobFunction · 0.85
_toJsonBodyFunction · 0.85
_toTextBodyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…