mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
10 lines
334 B
TypeScript
10 lines
334 B
TypeScript
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()
|
|
})
|
|
}
|