Skip to content

Commit

Permalink
Update index.ts
Browse files Browse the repository at this point in the history
Add check for typeof window, fallback to throttle if undefined
  • Loading branch information
cherealnice authored Oct 27, 2024
1 parent 75e3f8e commit 392b650
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/scheduled/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const throttle: ScheduleCallback = (callback, wait) => {
export const scheduleIdle: ScheduleCallback = isServer
? () => Object.assign(() => void 0, { clear: () => void 0 })
: // requestIdleCallback is not supported in Safari
(window.requestIdleCallback as typeof window.requestIdleCallback | undefined)
(typeof window !== 'undefined' && window.requestIdleCallback as typeof window.requestIdleCallback | undefined)
? (callback, maxWait) => {
let isDeferred = false,
id: ReturnType<typeof requestIdleCallback>,
Expand Down

0 comments on commit 392b650

Please sign in to comment.