forked from dorey/JavaScript-Equality-Table
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
2 lines (2 loc) · 2.02 KB
/
Copy pathbundle.js
File metadata and controls
2 lines (2 loc) · 2.02 KB
1
2
(()=>{var d=window.TABLE_VALUES,T=document.querySelector.bind(document),$=document.querySelectorAll.bind(document),i=(l,t="",s="")=>{let e=document.createElement(l);return e.className=t,e.textContent=s,e},p=class{constructor(t){this.item=t;this.asString="";this.asString=`${t}`,typeof t=="string"?this.asString=`"${t}"`:Array.isArray(this.item)?this.asString=JSON.stringify(this.item):this.item instanceof Object&&(this.asString="{}")}testResults(t){let s=""+this.asString+"==="+t.asString,e=""+this.asString+"=="+t.asString,a=(0,eval)("("+s+")"),r=(0,eval)("("+e+")"),n="not equal";return a&&r?n="strictly equal":r&&(n="loosely equal"),[`${this.asString} ${n} ${t}`,n]}toString(){return this.asString}},g=class{constructor(){this.asString="if (x)"}testResults(t){let s=`${t} ? true : false`,e=(0,eval)("("+s+")");return[`if (${t}) is ${e}`,e]}},m=class{constructor(t){this.node=t;if(!d)return;let s=new g,e=d.map(n=>new p(n)),a=i("table","table"),r=i("tr","header");r.appendChild(document.createElement("td")),a.appendChild(r),r.appendChild(this.createTableHeaderCell(s.asString));for(let n of e)r.appendChild(this.createTableHeaderCell(n.asString));for(let n of e){let o=i("tr","row"),S=i("td","term",n.asString);o.appendChild(S);let[h,c]=s.testResults(n),y=`bg-yellow ${c?"bg-no-invert":""}`;o.appendChild(this.createTableCell(y,c?"\u2714\uFE0F":"-",h));let b={"strictly equal":"=","loosely equal":"≅","not equal":"≠"},C={"strictly equal":"bg-green bg-no-invert","loosely equal":"bg-red bg-no-invert","not equal":"bg-blue"};for(let f of e){let[q,u]=n.testResults(f);o.appendChild(this.createTableCell(C[u],b[u],q))}a.appendChild(o)}this.node.appendChild(a)}createTableHeaderCell(t){let s=i("span","rotate",t),e=i("td","term-vertical");return e.appendChild(s),e}createTableCell(t,s,e){let a=i("td",`equality ${t}`);return a.innerHTML=`<code class="equality-item">${s}</code>`,a.setAttribute("data-title",e),a}},E={ComparisonTable:m};$("[data-component]").forEach(l=>{let t=E[l.dataset.component];t&&new t(l)});})();
//# sourceMappingURL=bundle.js.map