14 lines
No EOL
287 B
TypeScript
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
|
|
})
|
|
)
|
|
}
|
|
} |