MCPcopy Index your code
hub / github.com/tensorflow/tfjs / urlChunkIterator

Function urlChunkIterator

tfjs-data/src/iterators/url_chunk_iterator.ts:29–47  ·  view source on GitHub ↗
(
    url: RequestInfo, options: FileChunkIteratorOptions = {},
    fetchFunc?: Function)

Source from the content-addressed store, hash-verified

27 * yet reliably provide a reader stream for the response body.
28 */
29export async function urlChunkIterator(
30 url: RequestInfo, options: FileChunkIteratorOptions = {},
31 fetchFunc?: Function) {
32 let urlString;
33 let requestInit;
34 if ((typeof url) === 'string') {
35 urlString = url as string;
36 } else {
37 urlString = (url as Request).url;
38 requestInit = getRequestInitFromRequest(url as Request);
39 }
40 const response = await (fetchFunc || util.fetch)(urlString, requestInit);
41 if (response.ok) {
42 const uint8Array = new Uint8Array(await response.arrayBuffer());
43 return new FileChunkIterator(uint8Array, options);
44 } else {
45 throw new Error(response.statusText);
46 }
47}
48
49// Generate RequestInit from Request to match tf.util.fetch signature.
50const getRequestInitFromRequest = (request: Request) => {

Callers 2

iteratorMethod · 0.90

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…