MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / decompressFile

Method decompressFile

data/src/compression.js:110–139  ·  view source on GitHub ↗
(method, data, updateMsg, fileCbFunc)

Source from the content-addressed store, hash-verified

108 })
109 }
110 decompressFile(method, data, updateMsg, fileCbFunc) {
111 return new Promise(async callback => {
112 const file = await this.getWorkerFile(method);
113 const worker = new Worker(URL.createObjectURL(file));
114 const files = {};
115 worker.onmessage = (data) => {
116 if (!data.data) return;
117 //data.data.t/ 4=progress, 2 is file, 1 is zip done
118 if (data.data.t === 4) {
119 const pg = data.data;
120 const num = Math.floor(pg.current / pg.total * 100);
121 if (isNaN(num)) return;
122 const progress = " " + num.toString() + "%";
123 updateMsg(progress, true);
124 }
125 if (data.data.t === 2) {
126 if (typeof fileCbFunc === "function") {
127 fileCbFunc(data.data.file, data.data.data);
128 files[data.data.file] = true;
129 } else {
130 files[data.data.file] = data.data.data;
131 }
132 }
133 if (data.data.t === 1) {
134 callback(files);
135 }
136 }
137 worker.postMessage(data);
138 });
139 }
140}
141
142window.EJS_COMPRESSION = EJS_COMPRESSION;

Callers 1

decompressMethod · 0.95

Calls 1

getWorkerFileMethod · 0.95

Tested by

no test coverage detected