Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/samualtnorman/lib. A collection of common utilities I need. www.npmjs.com/package/@samual/lib
Something went wrong. Try again.
123456789101112131415const { port1, port2 } = new MessageChannelconst tasks: (() => void)[] = []
port2.onmessage = () => { for (const task of tasks.splice(0)) task()}
export function queueTask(callback: () => void): void { if (!tasks.length) port1.postMessage(undefined)
tasks.push(callback)}