src/index.js
function onVisibilityChangeFactory(hidden) {
  return function onVisibilityChange(evt) {
    if (document[hidden]) {
      debug('disable while hidden');
      stop();
    } else {
      debug('enable while visible');
      if (process.env.NODE_ENV === 'development') {
        const current = now();

        for (let i = 0, n = timeoutQueue.length; i < n; i++) {
          const item = timeoutQueue[i];

          if (item.time <= current) {
            debug('timeout should trigger for "%s"', item.id);
          } else {
            const date = new Date();

            date.setMilliseconds(date.getMilliseconds() + item.time - current);
            debug('timeout for "%s" expected at %s', item.id, date.toLocaleTimeString());
          }
        }
      }
      run();
    }
  };
}
function onVisibilityChangeFactory(hidden) {
  return function onVisibilityChange(evt) {
    if (document[hidden]) {
      debug('disable while hidden');
      stop();
    } else {
      debug('enable while visible');
      if (process.env.NODE_ENV === 'development') {
        const current = now();

        for (let i = 0, n = timeoutQueue.length; i < n; i++) {
          const item = timeoutQueue[i];

          if (item.time <= current) {
            debug('timeout should trigger for "%s"', item.id);
          } else {
            const date = new Date();

            date.setMilliseconds(date.getMilliseconds() + item.time - current);
            debug('timeout for "%s" expected at %s', item.id, date.toLocaleTimeString());
          }
        }
      }
      run();
    }
  };
}
function onVisibilityChangeFactory ( hidden ) { return function onVisibilityChange ( evt ) { if ( document [ hidden ] ) { debug ( 'disable while hidden' ) ; stop ( ) ; } else { debug ( 'enable while visible' ) ; if ( process . env . NODE_ENV === 'development' ) { const current = now ( ) ; for ( let i = 0 , n = timeoutQueue . length ; i < n ; i ++ ) { const item = timeoutQueue [ i ] ; if ( item . time <= current ) { debug ( 'timeout should trigger for "%s"' , item . id ) ; } else { const date = new Date ( ) ; date . setMilliseconds ( date . getMilliseconds ( ) + item . time - current ) ; debug ( 'timeout for "%s" expected at %s' , item . id , date . toLocaleTimeString ( ) ) ; } } } run ( ) ; } } ; }
Generate visibilityChange handler
@param {String} hidden
@returns {Function}
Generate visibilityChange handler