()
| 100 | }, |
| 101 | |
| 102 | stop() { |
| 103 | return new Promise<void>((resolve) => { |
| 104 | let settled = false; |
| 105 | const finish = (): void => { |
| 106 | if (settled) return; |
| 107 | settled = true; |
| 108 | // Worker has cleared (or been terminated off) the animation line; |
| 109 | // persist the final phase's done-line from the main thread. |
| 110 | printPhaseDone(); |
| 111 | resolve(); |
| 112 | }; |
| 113 | |
| 114 | const timeout = setTimeout(() => { |
| 115 | worker.terminate().then(finish); |
| 116 | }, 2000); |
| 117 | |
| 118 | worker.on('message', (msg: { type: string }) => { |
| 119 | if (msg.type === 'stopped') { |
| 120 | clearTimeout(timeout); |
| 121 | worker.terminate().then(finish); |
| 122 | } |
| 123 | }); |
| 124 | |
| 125 | worker.postMessage({ type: 'stop' }); |
| 126 | }); |
| 127 | }, |
| 128 | }; |
| 129 | } |
| 130 |
nothing calls this directly
no test coverage detected