k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/gopherage/cmd/html/static/zz.browser.bundle.min.js (about)

     1  function*map(e,t){for(const n of e)yield t(n)}function reduce(e,t,n){let r=n;for(const n of e)r=t(r,n);return r}function*filter(e,t){for(const n of e)t(n)&&(yield n)}function*enumerate(e){let t=0;for(const n of e)yield[t++,n]}var __rest=window&&window.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};class FileCoverage{constructor(e,t){this.filename=e,this.fileNumber=t,this.blocks=new Map}addBlock(e){const t=this.keyForBlock(e),n=this.blocks.get(t);n?n.hits+=e.hits:this.blocks.set(t,e)}get totalStatements(){return reduce(this.blocks.values(),(e,t)=>e+t.statements,0)}get coveredStatements(){return reduce(this.blocks.values(),(e,t)=>e+(t.hits>0?t.statements:0),0)}keyForBlock(e){return`${e.start.line}.${e.start.col},${e.end.line}.${e.end.col}`}}class Coverage{constructor(e,t=""){this.mode=e,this.prefix=t,this.files=new Map}addFile(e){this.files.set(e.filename,e)}getFile(e){return this.files.get(e)}getFilesWithPrefix(e){return new Map(filter(this.files.entries(),([t])=>t.startsWith(this.prefix+e)))}getCoverageForPrefix(e){const t=new Coverage(this.mode,this.prefix+e);for(const[n,r]of this.files)n.startsWith(this.prefix+e)&&t.addFile(r);return t}get children(){const e=new Map;for(const t of this.files.keys()){let[n,r]=t.substr(this.prefix.length).split("/",2);e.has(n)||(r&&(n+="/"),e.set(n,this.getCoverageForPrefix(n)))}return e}get basename(){return this.prefix.endsWith("/")?this.prefix.substring(0,this.prefix.length-1).split("/").pop()+"/":this.prefix.split("/").pop()}get totalStatements(){return reduce(this.files.values(),(e,t)=>e+t.totalStatements,0)}get coveredStatements(){return reduce(this.files.values(),(e,t)=>e+t.coveredStatements,0)}get totalFiles(){return this.files.size}get coveredFiles(){return reduce(this.files.values(),(e,t)=>e+(t.coveredStatements>0?1:0),0)}}function parseCoverage(e){const t=e.split("\n"),n=t.shift(),[r,o]=n.split(":").map(e=>e.trim());if("mode"!==r)throw new Error("Expected to start with mode line.");t.sort((e,t)=>(e=e.split(":",2)[0])<(t=t.split(":",2)[0])?-1:e>t?1:0);const i=new Coverage(o);let s=0;for(const e of t){if(""===e)continue;const t=parseLine(e),{filename:n}=t,r=__rest(t,["filename"]);let o=i.getFile(n);o||(o=new FileCoverage(n,s++),i.addFile(o)),o.addBlock(r)}return i}function parseLine(e){const[t,n]=e.split(":"),[r,o,i]=n.split(" "),[s,a]=r.split(","),[l,c]=s.split(".").map(parseInt),[f,d]=a.split(".").map(parseInt);return{end:{col:d,line:f},filename:t,hits:Math.max(0,Number(i)),start:{col:c,line:l},statements:Number(o)}}var __awaiter=window&&window.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){e.done?o(e.value):function t(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(s,a)}l((r=r.apply(e,t||[])).next())}))};let coverageFiles=[],gPrefix="";function filenameForDisplay(e){return e.split("/").pop().replace(/\.[^.]+$/,"")}function loadEmbeddedProfiles(){return embeddedProfiles.map(({path:e,content:t})=>({coverage:parseCoverage(t),name:filenameForDisplay(e)}))}function init(){return __awaiter(this,void 0,void 0,(function*(){location.hash.length>1&&(gPrefix=location.hash.substring(1)),coverageFiles=loadEmbeddedProfiles(),google.charts.load("current",{packages:["table"]}),google.charts.setOnLoadCallback(drawTable)}))}function updateBreadcrumb(){const e=gPrefix.split("/"),t=document.getElementById("breadcrumbs");t.innerHTML="";let n="";for(const r of e){if(!r)continue;n+=r+"/";const e=document.createElement("a");e.href=`#${n}`,e.innerText=r,t.appendChild(e),t.appendChild(document.createTextNode("/"))}}function coveragesForPrefix(e,t){const n=mergeMaps(map(e,e=>e.getCoverageForPrefix(t).children)),r=Array.from(n.keys());return r.sort(),console.log(n),map(r,e=>({c:[{v:e}].concat(n.get(e).map((t,r)=>{if(!t)return{v:""};const o=n.get(e)[r+1],i=t.coveredStatements/t.totalStatements;let s="";if(o){const e=o.coveredStatements/o.totalStatements;i>e?s="▲":i<e&&(s="▼")}return{f:`<span class="arrow">${s}</span> ${`${(100*i).toFixed(1)}%`}`,v:i}}))}))}function mergeMaps(e){const t=new Map;for(const[n,r]of enumerate(e)){for(const[e,o]of r.entries())t.has(e)||t.set(e,Array(n).fill(null)),t.get(e).push(o);for(const e of t.values())e.length===n&&e.push(null)}return t}function drawTable(){const e=Array.from(coveragesForPrefix(coverageFiles.map(e=>e.coverage),gPrefix)),t=coverageFiles.map((e,t)=>({id:`file-${t}`,label:e.name,type:"number"})),n=new google.visualization.DataTable({cols:[{id:"child",label:"File",type:"string"}].concat(t),rows:e}),r=new google.visualization.ColorFormat;r.addGradientRange(0,1.0001,"#FFFFFF","#DD0000","#00DD00");for(let e=1;e<t.length+1;++e)r.format(n,e);const o=new google.visualization.Table(document.getElementById("table"));o.draw(n,{allowHtml:!0}),google.visualization.events.addListener(o,"select",()=>{const t=e[o.getSelection()[0].row].c[0].v;t.endsWith("/")&&(location.hash=gPrefix+t)}),updateBreadcrumb()}document.addEventListener("DOMContentLoaded",()=>init()),window.addEventListener("hashchange",()=>{gPrefix=location.hash.substring(1),drawTable()});