Skip to content

Commit

Permalink
fix: use new global-this package & remove global type & prevent sid…
Browse files Browse the repository at this point in the history
…ee-ffects
  • Loading branch information
mohammadhonarvar committed Oct 11, 2024
1 parent 10c5ffc commit 092d448
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/delay/src/polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {globalScope} from '@alwatr/global-this';
import {getGlobalThis, type GlobalThis} from '@alwatr/global-this';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const win = globalScope as DictionaryOpt<any>;
export const win = /* #__PURE__ */ getGlobalThis();

// prettier-ignore
const requestAnimationFrameFallback =
(callback: FrameRequestCallback): ReturnType<typeof setTimeout> =>
setTimeout(() => callback(Date.now()), 1000 / 60);

// prettier-ignore
export const requestAnimationFrame: typeof globalScope.requestAnimationFrame =
export const requestAnimationFrame: GlobalThis['requestAnimationFrame'] =
win.requestAnimationFrame ||
win.webkitRequestAnimationFrame ||
win.mozRequestAnimationFrame ||
Expand All @@ -21,7 +20,7 @@ const requestIdleCallbackFallback =
setTimeout(callback, options?.timeout ?? 2000);

// prettier-ignore
export const requestIdleCallback: typeof globalScope.requestIdleCallback =
export const requestIdleCallback: GlobalThis['requestIdleCallback'] =
win.requestIdleCallback ||
win.webkitRequestIdleCallback ||
win.mozRequestIdleCallback ||
Expand Down

0 comments on commit 092d448

Please sign in to comment.