import { Effect , Effects , get , TimerEnv } from '@typed/effects' ; import { Resume } from '@typed/env' ; import { RequestIdleCallbackDeadline , whenIdleWithTimeout } from '@typed/timer' ; export function * requestIdleCallback ( timeout = Number . MAX_SAFE_INTEGER ) { const { timer } = yield * get < TimerEnv > ( ) ; return yield * Effect . fromEnv ( ( _ ) => Resume . create < RequestIdleCallbackDeadline > ( ( cb ) => whenIdleWithTimeout ( cb , timeout , timer ) ) ) ; }