boleto-barcode-svg
Version:
Generate brazilian boleto barcode in SVG
3 lines (2 loc) • 916 B
JavaScript
function n(n){return'<rect y="0" height="100%" fill="'+n.fill+'" width="'+n.width+'" x="'+n.x+'"></rect>'}var r=["11221","21112","12112","22111","11212","21211","12211","11122","21121","12121"];function t(n){for(var t=r[Math.floor(n/10)],i=r[n%10],e="",o=0;o<5;o+=1)e+=t[o],e+=i[o];return e}function i(r){return d=(i=function(n){return n.split("").map(Number)}(function(n){return"1111"+n.match(/(..?)/g).map(t).join("")+"211"}(r=function(n){return n.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((c=0,function(n,r){var t={x:c,width:n*u,fill:r%2?o:e};return c+=t.width,t}))).map(n),['<svg viewBox="0 0 '+((f=i[i.length-1]).width+f.x)+' 100">',(a=d,void 0===a&&(a=[]),a.map(function(n){return" "+n}).join("\n")),"</svg>"].join("\n");var i,f,a,d,c}var e="#000",o="#fff",u=4;export{i as boletoBarcodeSvg};
//# sourceMappingURL=boleto-barcode-svg.esm.js.map