lighthouse-plugin-publisher-ads/audits/ad-request-critical-path.js
/**
 * Computes idle times in the network loading graph
 * @param {SimpleRequest[]} blockingRequests A list of request that appear in
 *     the ad loading graph.
 * @return {number[]} List of idle durations.
 */
Computes idle times in the network loading graph
@param {SimpleRequest[]} blockingRequests A list of request that appear in
the ad loading graph.
@return {number[]} List of idle durations.
Computes idle times in the network loading graph @param { SimpleRequest [] } blockingRequests A list of request that appear in the ad loading graph . @return { number [] } List of idle durations .
function computeIdleTimes(blockingRequests) {
  let maxEndSoFar = Infinity;
  const idleTimes = [];
  for (let i = 0; i < blockingRequests.length;) {
    const {startTime, endTime} = blockingRequests[i];
    if (startTime - maxEndSoFar > MINIMUM_NOTEWORTHY_IDLE_GAP_MS) {
      idleTimes.push(startTime - maxEndSoFar);
    }
    maxEndSoFar = endTime;
    while (++i < blockingRequests.length &&
        blockingRequests[i].startTime < maxEndSoFar) {
      maxEndSoFar = Math.max(maxEndSoFar, blockingRequests[i].endTime);
    }
  }
  return idleTimes;
}
function computeIdleTimes ( blockingRequests ) { let maxEndSoFar = Infinity ; const idleTimes = [ ] ; for ( let i = 0 ; i < blockingRequests . length ; ) { const { startTime , endTime } = blockingRequests [ i ] ; if ( startTime - maxEndSoFar > MINIMUM_NOTEWORTHY_IDLE_GAP_MS ) { idleTimes . push ( startTime - maxEndSoFar ) ; } maxEndSoFar = endTime ; while ( ++ i < blockingRequests . length && blockingRequests [ i ] . startTime < maxEndSoFar ) { maxEndSoFar = Math . max ( maxEndSoFar , blockingRequests [ i ] . endTime ) ; } } return idleTimes ; }
Computes idle times in the network loading graph
 @param {SimpleRequest[]} blockingRequests A list of request that appear in
     the ad loading graph.
Computes idle times in the network loading graph @param { SimpleRequest [] } blockingRequests A list of request that appear in the ad loading graph .