(currentBytes?: number, totalBytes?: number)
| 253 | const tasksWithProgress = tasks.map((task, index) => async () => { |
| 254 | const fileNumber = index + 1; |
| 255 | const emitProgress = (currentBytes?: number, totalBytes?: number) => { |
| 256 | if (isPositiveFiniteNumber(totalBytes)) { |
| 257 | taskTotalBytes.set(index, totalBytes); |
| 258 | } |
| 259 | if (currentBytes !== undefined) { |
| 260 | const knownTotal = taskTotalBytes.get(index); |
| 261 | const boundedBytes = knownTotal |
| 262 | ? Math.max(0, Math.min(currentBytes, knownTotal)) |
| 263 | : Math.max(0, currentBytes); |
| 264 | taskLoadedBytes.set(index, boundedBytes); |
| 265 | } |
| 266 | const totalTransferBytes = getTotalTransferBytes(); |
| 267 | onProgress?.({ |
| 268 | phase: "files", |
| 269 | operation, |
| 270 | currentFile: task.label, |
| 271 | completedFiles: completed, |
| 272 | totalFiles: total, |
| 273 | ...(currentBytes !== undefined ? { currentBytes } : {}), |
| 274 | ...(totalBytes !== undefined ? { totalBytes } : {}), |
| 275 | ...(taskLoadedBytes.size > 0 ? { totalCurrentBytes: getTotalCurrentBytes() } : {}), |
| 276 | ...(totalTransferBytes !== undefined ? { totalTransferBytes } : {}), |
| 277 | message: `${operationLabel} file ${fileNumber}/${total}...`, |
| 278 | }); |
| 279 | }; |
| 280 | |
| 281 | emitProgress(); |
| 282 | const result = await task.run((loaded, taskTotal) => { |
no test coverage detected