UNPKG

boleto-barcode-svg

Version:

Generate brazilian boleto barcode in SVG

3 lines (2 loc) 943 B
function t({fill:t,width:n,x:r}){return`<rect y="0" height="100%" fill="${t}" width="${n}" x="${r}"></rect>`}function n(t=[]){return t.map(t=>" "+t).join("\n")}const r=["11221","21112","12112","22111","11212","21211","12211","11122","21121","12121"];function e(t){const n=r[Math.floor(t/10)],e=r[t%10];let i="";for(let t=0;t<5;t+=1)i+=n[t],i+=e[t];return i}function i(r){return function(r){const e=r.map(t);return[`<svg viewBox="0 0 ${(({width:t,x:n})=>t+n)(r[r.length-1])} 100">`,n(e),"</svg>"].join("\n")}(function(t){return t.split("").map(Number)}(function(t){return"1111"+t.match(/(..?)/g).map(e).join("")+"211"}(r=function(t){return t.replace(/\D/g,"").replace(/^(\d{4})(\d{5})\d{1}(\d{10})\d{1}(\d{10})\d{1}(\d{15})$/,"$1$5$2$3$4")}(r))).map((i=0,(t,n)=>{const r={x:i,width:t*u,fill:n%2?c:o};return i+=r.width,r})));var i}const o="#000",c="#fff",u=4;export{i as boletoBarcodeSvg}; //# sourceMappingURL=boleto-barcode-svg.modern.js.map