fix fix yield.

This commit is contained in:
fiatjaf
2023-12-20 10:49:08 -03:00
parent 8625d45152
commit 0cc3c02d84
3 changed files with 12 additions and 9 deletions

9
helpers.ts Normal file
View File

@@ -0,0 +1,9 @@
export async function yieldThread() {
return new Promise(resolve => {
const ch = new MessageChannel()
// @ts-ignore (typescript thinks this property should be called `addListener`, but in fact it's `addEventListener`)
ch.port1.addEventListener('message', resolve)
ch.port2.postMessage(0)
ch.port1.start()
})
}