(progress: IndexProgress)
| 29 | |
| 30 | return { |
| 31 | onProgress(progress: IndexProgress) { |
| 32 | const phaseName = PHASE_NAMES[progress.phase] || progress.phase; |
| 33 | |
| 34 | if (progress.phase !== lastPhase && lastPhase) { |
| 35 | worker.postMessage({ type: 'finish-phase' }); |
| 36 | } |
| 37 | lastPhase = progress.phase; |
| 38 | |
| 39 | let percent = -1; |
| 40 | let count = 0; |
| 41 | if (progress.total > 0) { |
| 42 | percent = Math.round((progress.current / progress.total) * 100); |
| 43 | } else if (progress.current > 0) { |
| 44 | count = progress.current; |
| 45 | } |
| 46 | |
| 47 | worker.postMessage({ |
| 48 | type: 'update', |
| 49 | phase: progress.phase, |
| 50 | phaseName, |
| 51 | percent, |
| 52 | count, |
| 53 | }); |
| 54 | }, |
| 55 | |
| 56 | stop() { |
| 57 | return new Promise<void>((resolve) => { |
no test coverage detected