UNPKG

@studiometa/js-toolkit

Version:

A set of useful little bits of JavaScript to boost your project! 🚀

13 lines (12 loc) • 371 B
import { isFunction } from "./is.js"; import { hasWindow } from "./has.js"; function nextFrame(callback) { const fn = hasWindow() ? window?.requestAnimationFrame ?? setTimeout : setTimeout; return new Promise((resolve) => { fn((time) => resolve(isFunction(callback) ? callback(time) : time)); }); } export { nextFrame }; //# sourceMappingURL=nextFrame.js.map