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

Function _toBlob

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

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

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

Source from the content-addressed store, hash-verified

161 * Helper function to convert a response body to a Blob.
162 */
163function _toBlob(
164 body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[],
165): Blob {
166 if (typeof Blob === 'undefined') {
167 throw new Error('Blob responses are not supported on this platform.');
168 }
169 if (body instanceof Blob) {
170 return body;
171 }
172 if (ArrayBuffer && body instanceof ArrayBuffer) {
173 return new Blob([body]);
174 }
175 throw new Error('Automatic conversion to Blob is not supported for response type.');
176}
177
178/**
179 * Helper function to convert a response body to JSON data.

Callers 1

_maybeConvertBodyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…