feat: init
This commit is contained in:
1
apps/web/core/lib/polyfills/index.ts
Normal file
1
apps/web/core/lib/polyfills/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./requestIdleCallback";
|
||||
24
apps/web/core/lib/polyfills/requestIdleCallback.ts
Normal file
24
apps/web/core/lib/polyfills/requestIdleCallback.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
if (typeof window !== "undefined" && window) {
|
||||
// Add request callback polyfill to browser in case it does not exist
|
||||
window.requestIdleCallback =
|
||||
window.requestIdleCallback ??
|
||||
function (cb) {
|
||||
const start = Date.now();
|
||||
return setTimeout(function () {
|
||||
cb({
|
||||
didTimeout: false,
|
||||
timeRemaining: function () {
|
||||
return Math.max(0, 50 - (Date.now() - start));
|
||||
},
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
|
||||
window.cancelIdleCallback =
|
||||
window.cancelIdleCallback ??
|
||||
function (id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
}
|
||||
|
||||
export {};
|
||||
Reference in New Issue
Block a user