All files / app/assets/javascripts/commons polyfills.js

28.57% Statements 2/7
50% Branches 2/4
0% Functions 0/4
28.57% Lines 2/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25              4x                       4x          
/**
 * Polyfill
 * @what requestIdleCallback
 * @why To align browser features
 * @browsers Safari (all versions)
 * @see https://caniuse.com/#feat=requestidlecallback
 */
window.requestIdleCallback =
  window.requestIdleCallback ||
  function requestShim(cb) {
    const start = Date.now();
    return setTimeout(() => {
      cb({
        didTimeout: false,
        timeRemaining: () => Math.max(0, 50 - (Date.now() - start)),
      });
    }, 1);
  };
 
window.cancelIdleCallback =
  window.cancelIdleCallback ||
  function cancelShim(id) {
    clearTimeout(id);
  };