mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2024-11-27 20:12:17 +00:00
15 lines
420 B
TypeScript
15 lines
420 B
TypeScript
type NextTickFn = (callback: () => void) => void;
|
|
|
|
/* c8 ignore start */
|
|
const nextTickFn =
|
|
typeof setImmediate !== 'undefined'
|
|
? (setImmediate as NextTickFn)
|
|
: typeof requestAnimationFrame !== 'undefined'
|
|
? (requestAnimationFrame as NextTickFn)
|
|
: (setTimeout as NextTickFn);
|
|
/* c8 ignore stop */
|
|
|
|
export async function nextTickAsync() {
|
|
return new Promise<void>((resolve) => nextTickFn(resolve));
|
|
}
|