UNPKG

@datawheel/bespoke-cms-warmup

Version:

Warmup utility for Bespoke CMS pages

1 lines 679 B
'use strict';var u=(t,e)=>()=>(t&&(e=t(t=0)),e);var a=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var c=u(()=>{});var f=a((w,l)=>{c();l.exports={pageAutoScroll:i,xhrTestHandler:d};async function d(t){return new Promise(e=>{let r=[];t.on("requestfinished",async n=>{let s=n.failure();s&&r.push({url:n.url(),error:s.errorText});let o=n.response();o&&!o.ok()&&r.push({url:o.url(),code:o.status(),error:await o.text()});}),t.evaluate(i).then(()=>{e(r);});})}function i(){return new Promise(t=>{let e=0,r=400,n=setInterval(()=>{let s=document.body.scrollHeight;window.scrollBy(0,r),e+=r,e>=s&&(clearInterval(n),t());},200);})}});var test_xhr = f();module.exports=test_xhr;