UNPKG

js-uploader

Version:
25 lines 1.01 kB
import { Logger } from '../shared/Logger'; export var scheduleWork = function (callback, timeout) { if (typeof callback !== 'function') { return; } if (typeof window !== 'undefined') { if ('requestIdleCallback' in window) { Logger.warn('scheduleWork : use requestIdleCallback!'); window.requestIdleCallback(function (idle) { return callback(function () { return idle.timeRemaining(); }); }, { timeout: timeout }); } else if ('requestAnimationFrame' in window) { Logger.warn('scheduleWork : use requestAnimationFrame!'); window.requestAnimationFrame(function () { return callback(); }); } else { Logger.warn('scheduleWork : use setTimeout!'); setTimeout(function () { return callback(); }); } } else { Logger.warn('scheduleWork : use setTimeout!'); setTimeout(function () { return callback(); }); } }; //# sourceMappingURL=schedule-work.js.map