dd-trace
Version:
Datadog APM tracing client for JavaScript
1 lines • 7.13 kB
JavaScript
(()=>{"use strict";var e={"./istanbul-lib-coverage/index.js":function(e,t,a){let{FileCoverage:r}=a("./istanbul-lib-coverage/lib/file-coverage.js"),{CoverageMap:s}=a("./istanbul-lib-coverage/lib/coverage-map.js"),{CoverageSummary:n}=a("./istanbul-lib-coverage/lib/coverage-summary.js");e.exports={createCoverageSummary:e=>e&&e instanceof n?e:new n(e),createCoverageMap:e=>e&&e instanceof s?e:new s(e),createFileCoverage:e=>e&&e instanceof r?e:new r(e)},e.exports.classes={FileCoverage:r}},"./istanbul-lib-coverage/lib/coverage-map.js":function(e,t,a){let{FileCoverage:r}=a("./istanbul-lib-coverage/lib/file-coverage.js"),{CoverageSummary:s}=a("./istanbul-lib-coverage/lib/coverage-summary.js");function n(e,t){return e instanceof t?e:new t(e)}class i{constructor(e){e instanceof i?this.data=e.data:this.data=function(e){let t=Object.create(null);return e&&Object.entries(e).forEach(([e,a])=>{t[e]=n(a,r)}),t}(e)}merge(e){Object.values(n(e,i).data).forEach(e=>{this.addFileCoverage(e)})}filter(e){Object.keys(this.data).forEach(t=>{e(t)||delete this.data[t]})}toJSON(){return this.data}files(){return Object.keys(this.data)}fileCoverageFor(e){let t=this.data[e];if(!t)throw Error(`No file coverage available for: ${e}`);return t}addFileCoverage(e){let t=new r(e),{path:a}=t;this.data[a]?this.data[a].merge(t):this.data[a]=t}getCoverageSummary(){let e=new s;return Object.values(this.data).forEach(t=>{e.merge(t.toSummary())}),e}}e.exports={CoverageMap:i}},"./istanbul-lib-coverage/lib/coverage-summary.js":function(e,t,a){let r=a("./istanbul-lib-coverage/lib/percent.js"),s=a("./istanbul-lib-coverage/lib/data-properties.js");class n{constructor(e){e?e instanceof n?this.data=e.data:this.data=e:this.data=function(){let e=()=>({total:0,covered:0,skipped:0,pct:"Unknown"});return{lines:e(),statements:e(),functions:e(),branches:e(),branchesTrue:e()}}(),function(e){if(!(e&&e.lines&&e.statements&&e.functions&&e.branches))throw Error("Invalid summary coverage object, missing keys, found:"+Object.keys(e).join(","))}(this.data)}merge(e){return["lines","statements","branches","functions","branchesTrue"].forEach(t=>{e[t]&&(this[t].total+=e[t].total,this[t].covered+=e[t].covered,this[t].skipped+=e[t].skipped,this[t].pct=r(this[t].covered,this[t].total))}),this}toJSON(){return this.data}isEmpty(){return 0===this.lines.total}}s(n,["lines","statements","functions","branches","branchesTrue"]),e.exports={CoverageSummary:n}},"./istanbul-lib-coverage/lib/data-properties.js":function(e){e.exports=function(e,t){t.forEach(t=>{Object.defineProperty(e.prototype,t,{enumerable:!0,get(){return this.data[t]}})})}},"./istanbul-lib-coverage/lib/file-coverage.js":function(e,t,a){let r=a("./istanbul-lib-coverage/lib/percent.js"),s=a("./istanbul-lib-coverage/lib/data-properties.js"),{CoverageSummary:n}=a("./istanbul-lib-coverage/lib/coverage-summary.js"),i=({start:e,end:t})=>`${e.line}|${e.column}|${t.line}|${t.column}`,o=e=>!!e&&"object"==typeof e,l=e=>o(e)&&"number"==typeof e.line&&"number"==typeof e.column,c=e=>o(e)&&l(e.start)&&l(e.end),u=e=>c(e)?e:c(e.loc)?e.loc:null,h=(e,t)=>{let a=u(e);if(!a)return null;let r=null,s=null,n=null;for(let[e,i]of Object.entries(t)){let t=u(i);if(!t)continue;let o=[a.start.line-t.start.line,a.start.column-t.start.column,t.end.line-a.end.line,t.end.column-a.end.column];if(o[0]<0||o[2]<0||0===o[0]&&o[1]<0||0===o[2]&&o[3]<0)continue;if(null===r){s=o,r=i,n=e;continue}let l=o[0]<s[0]||0===o[0]&&o[1]<s[1],c=o[2]<s[2]||0===o[2]&&o[3]<s[3];(l||c)&&(s=o,r=i,n=e)}return n},b=(e,t)=>"number"==typeof e&&"number"==typeof t?e+t:Array.isArray(e)&&Array.isArray(t)?e.map((e,a)=>(e||0)+(t[a]||0)):null,f=(e,t,a,r)=>{let s=h(e,a);return s?b(t,r[s]):t},p=(e,t,a,r,s=i)=>{let n={};for(let[a,r]of Object.entries(e)){let e=t[a];n[s(e)]=[r,e]}let o={};for(let[e,t]of Object.entries(a)){let a=r[e];o[s(a)]=[t,a]}let l={};for(let[e,t]of Object.entries(n)){let s=t[0],n=t[1],i=o[e];s=i?b(s,i[0]):f(n,s,r,a),l[e]=[s,n]}for(let[a,r]of Object.entries(o)){let s=r[0],n=r[1];l[a]||(s=f(n,s,t,e),l[a]=[s,n])}let c={},u={};return Object.values(l).forEach(([e,t],a)=>{c[a]=e,u[a]=t}),[c,u]};class d{constructor(e,t=!1){if(!e)throw Error("Coverage must be initialized with a path or an object");if("string"==typeof e)this.data=function(e,t){let a={path:e,statementMap:{},fnMap:{},branchMap:{},s:{},f:{},b:{}};return t&&(a.bT={}),a}(e,t);else if(e instanceof d)this.data=e.data;else if("object"==typeof e)this.data=e;else throw Error("Invalid argument to coverage constructor");!function(e){if(!(e&&e.path&&e.statementMap&&e.fnMap&&e.branchMap&&e.s&&e.f&&e.b))throw Error("Invalid file coverage object, missing keys, found:"+Object.keys(e).join(","))}(this.data)}getLineCoverage(){let e=this.data.statementMap,t=this.data.s,a=Object.create(null);return Object.entries(t).forEach(([t,r])=>{if(!e[t])return;let{line:s}=e[t].start,n=a[s];(void 0===n||n<r)&&(a[s]=r)}),a}getUncoveredLines(){let e=this.getLineCoverage(),t=[];return Object.entries(e).forEach(([e,a])=>{0===a&&t.push(e)}),t}getBranchCoverageByLine(){let e=this.branchMap,t=this.b,a={};return Object.entries(e).forEach(([e,r])=>{let s=r.line||r.loc.start.line,n=t[e];a[s]=a[s]||[],a[s].push(...n)}),Object.entries(a).forEach(([e,t])=>{let r=t.filter(e=>e>0),s=r.length/t.length*100;a[e]={covered:r.length,total:t.length,coverage:s}}),a}toJSON(){return this.data}merge(e){if(!0===e.all)return;if(!0===this.all){this.data=e.data;return}let[t,a]=p(this.s,this.statementMap,e.s,e.statementMap);this.data.s=t,this.data.statementMap=a;let r=e=>i(e.locations[0]);[t,a]=p(this.f,this.fnMap,e.f,e.fnMap,e=>i(e.loc)),this.data.f=t,this.data.fnMap=a,[t,a]=p(this.b,this.branchMap,e.b,e.branchMap,r),this.data.b=t,this.data.branchMap=a,this.bT&&e.bT&&([t,a]=p(this.bT,this.branchMap,e.bT,e.branchMap,r),this.data.bT=t)}computeSimpleTotals(e){let t=this[e];"function"==typeof t&&(t=t.call(this));let a={total:Object.keys(t).length,covered:Object.values(t).filter(e=>!!e).length,skipped:0};return a.pct=r(a.covered,a.total),a}computeBranchTotals(e){let t=this[e],a={total:0,covered:0,skipped:0};return Object.values(t).forEach(e=>{a.covered+=e.filter(e=>e>0).length,a.total+=e.length}),a.pct=r(a.covered,a.total),a}resetHits(){let e=this.s,t=this.f,a=this.b,r=this.bT;Object.keys(e).forEach(t=>{e[t]=0}),Object.keys(t).forEach(e=>{t[e]=0}),Object.keys(a).forEach(e=>{a[e].fill(0)}),r&&Object.keys(r).forEach(e=>{r[e].fill(0)})}toSummary(){let e={};return e.lines=this.computeSimpleTotals("getLineCoverage"),e.functions=this.computeSimpleTotals("f","fnMap"),e.statements=this.computeSimpleTotals("s","statementMap"),e.branches=this.computeBranchTotals("b"),this.bT&&(e.branchesTrue=this.computeBranchTotals("bT")),new n(e)}}s(d,["path","statementMap","fnMap","branchMap","s","f","b","bT","all"]),e.exports={FileCoverage:d,findNearestContainer:h,addHits:b,addNearestContainerHits:f}},"./istanbul-lib-coverage/lib/percent.js":function(e){e.exports=function(e,t){return t>0?Math.floor(1e5*e/t/10)/100:100}}},t={},a=function a(r){var s=t[r];if(void 0!==s)return s.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,a),n.exports}("./istanbul-lib-coverage/index.js");module.exports=a})();