ConvoyPanel/resources/scripts/util/microTask.ts
2022-11-21 06:16:27 +00:00

14 lines
No EOL
287 B
TypeScript

// Polyfill
export function microTask(cb: () => void) {
if (typeof queueMicrotask === 'function') {
queueMicrotask(cb)
} else {
Promise.resolve()
.then(cb)
.catch((e) =>
setTimeout(() => {
throw e
})
)
}
}