(method, data, updateMsg, fileCbFunc)
| 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 | |
| 142 | window.EJS_COMPRESSION = EJS_COMPRESSION; |
no test coverage detected