src/chunk.js
/**
 * Delays calling the given function until the browser is notifying us
 * about a certain minimum budget or the timeout is reached.
 * @param {!Window} win
 * @param {number} minimumTimeRemaining Minimum number of millis idle
 *     budget for callback to fire.
 * @param {number} timeout in millis for callback to fire.
 * @param {function(?IdleDeadline)} fn Callback.
 * @visibleForTesting
 */
Delays calling the given function until the browser is notifying us
about a certain minimum budget or the timeout is reached.
@param {!Window} win
@param {number} minimumTimeRemaining Minimum number of millis idle
budget for callback to fire.
@param {number} timeout in millis for callback to fire.
@param {function(?IdleDeadline)} fn Callback.
Delays calling the given function until the browser is notifying us about a certain minimum budget or the timeout is reached . @param { !Window } win @param { number } minimumTimeRemaining Minimum number of millis idle budget for callback to fire . @param { number } timeout in millis for callback to fire . @param { function ( ?IdleDeadline ) } fn Callback .
function onIdle(win, minimumTimeRemaining, timeout, fn) {
  const startTime = Date.now();
  function rIC(info) {
    if (info.timeRemaining() < minimumTimeRemaining) {
      const remainingTimeout = timeout - (Date.now() - startTime);
      if (remainingTimeout <= 0 || info.didTimeout) {
        dev().fine(TAG, 'Timed out', timeout, info.didTimeout);
        fn(info);
      } else {
        dev().fine(TAG, 'Rescheduling with', remainingTimeout,
            info.timeRemaining());
        win.requestIdleCallback(rIC, {timeout: remainingTimeout});
      }
    } else {
      dev().fine(TAG, 'Running idle callback with ', minimumTimeRemaining);
      fn(info);
    }
  }
  win.requestIdleCallback(rIC, {timeout});
}
function onIdle ( win , minimumTimeRemaining , timeout , fn ) { const startTime = Date . now ( ) ; function rIC ( info ) { if ( info . timeRemaining ( ) < minimumTimeRemaining ) { const remainingTimeout = timeout - ( Date . now ( ) - startTime ) ; if ( remainingTimeout <= 0 || info . didTimeout ) { dev ( ) . fine ( TAG , 'Timed out' , timeout , info . didTimeout ) ; fn ( info ) ; } else { dev ( ) . fine ( TAG , 'Rescheduling with' , remainingTimeout , info . timeRemaining ( ) ) ; win . requestIdleCallback ( rIC , { timeout : remainingTimeout } ) ; } } else { dev ( ) . fine ( TAG , 'Running idle callback with ' , minimumTimeRemaining ) ; fn ( info ) ; } } win . requestIdleCallback ( rIC , { timeout } ) ; }
Delays calling the given function until the browser is notifying us
 about a certain minimum budget or the timeout is reached.
Delays calling the given function until the browser is notifying us about a certain minimum budget or the timeout is reached .