MCPcopy
hub / github.com/tensorflow/tfjs / fetchAndUnzipTfjsDebuggerBundle

Function fetchAndUnzipTfjsDebuggerBundle

scripts/start_local_debugger_server.js:63–108  ·  view source on GitHub ↗
(version)

Source from the content-addressed store, hash-verified

61}
62
63async function fetchAndUnzipTfjsDebuggerBundle(version) {
64 let resp;
65 try {
66 resp = await new Promise(resolve => {
67 const fileUrl =
68 `${TFJS_DEBUGGER_BUNDLE_URL_BASE}/tfjs-debugger_${version}.zip`;
69 fetch(fileUrl).then(response => {
70 if (!response.ok) {
71 throw new Error(`Failed to load bundle: ${fileUrl}`);
72 }
73 resolve(response);
74 })
75 });
76 } catch (e) {
77 console.error(e.message);
78 }
79 const buffer = await resp.buffer();
80
81 // Read zip objects.
82 const zipObjects = await new Promise(resolve => {
83 const zipObjects = [];
84 JSZip.loadAsync(buffer).then((zip) => {
85 zip.folder('dist').forEach((relativePath, zipObject) => {
86 zipObjects.push(zipObject);
87 });
88 resolve(zipObjects);
89 })
90 });
91
92 // Read and index files content.
93 for (const zipObject of zipObjects) {
94 await new Promise(resolve => {
95 const name = zipObject.name;
96 zipObject
97 .async(
98 EXTS_WITH_ARRAY_BUFFER_CONTENT.some(ext => name.endsWith(ext)) ?
99 'nodebuffer' :
100 'text')
101 .then(content => {
102 const fileName = name.replace('dist/', '');
103 debuggerStaticFile[fileName] = content;
104 resolve();
105 });
106 });
107 }
108}
109
110const parser = new ArgumentParser({
111 description: 'Run tfjs-debugger locally that supports loading local packages',

Callers 1

mainFunction · 0.85

Calls 3

bufferMethod · 0.65
fetchFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…