+3
-0
@@ -0,1 +1,4 @@ | ||
| # 2.2.0 2020-08-31 | ||
| * Add $/+% to Code 39 lookup table. Thanks I P Susila! | ||
| # 2.1.0 2019-05-31 | ||
@@ -2,0 +5,0 @@ * Add GS1 128 type. Thanks Tom S! |
@@ -322,3 +322,3 @@ /* | ||
| var code39Data = [["1", 1, "110100101011"], ["2", 2, "101100101011"], ["3", 3, "110110010101"], ["4", 4, "101001101011"], ["5", 5, "110100110101"], ["6", 6, "101100110101"], ["7", 7, "101001011011"], ["8", 8, "110100101101"], ["9", 9, "101100101101"], ["0", 0, "101001101101"], ["A", 10, "110101001011"], ["B", 11, "101101001011"], ["C", 12, "110110100101"], ["D", 13, "101011001011"], ["E", 14, "110101100101"], ["F", 15, "101101100101"], ["G", 16, "101010011011"], ["H", 17, "110101001101"], ["I", 18, "101101001101"], ["J", 19, "101011001101"], ["K", 20, "110101010011"], ["L", 21, "101101010011"], ["M", 22, "110110101001"], ["N", 23, "101011010011"], ["O", 24, "110101101001"], ["P", 25, "101101101001"], ["Q", 26, "101010110011"], ["R", 27, "110101011001"], ["S", 28, "101101011001"], ["T", 29, "101011011001"], ["U", 30, "110010101011"], ["V", 31, "100110101011"], ["W", 32, "110011010101"], ["X", 33, "100101101011"], ["Y", 34, "110010110101"], ["Z", 35, "100110110101"], ["-", 36, "100101011011"], [".", 37, "110010101101"], [" ", 38, "100110101101"], ["*", NaN, "100101101101"]]; | ||
| var code39Data = [["1", 1, "110100101011"], ["2", 2, "101100101011"], ["3", 3, "110110010101"], ["4", 4, "101001101011"], ["5", 5, "110100110101"], ["6", 6, "101100110101"], ["7", 7, "101001011011"], ["8", 8, "110100101101"], ["9", 9, "101100101101"], ["0", 0, "101001101101"], ["A", 10, "110101001011"], ["B", 11, "101101001011"], ["C", 12, "110110100101"], ["D", 13, "101011001011"], ["E", 14, "110101100101"], ["F", 15, "101101100101"], ["G", 16, "101010011011"], ["H", 17, "110101001101"], ["I", 18, "101101001101"], ["J", 19, "101011001101"], ["K", 20, "110101010011"], ["L", 21, "101101010011"], ["M", 22, "110110101001"], ["N", 23, "101011010011"], ["O", 24, "110101101001"], ["P", 25, "101101101001"], ["Q", 26, "101010110011"], ["R", 27, "110101011001"], ["S", 28, "101101011001"], ["T", 29, "101011011001"], ["U", 30, "110010101011"], ["V", 31, "100110101011"], ["W", 32, "110011010101"], ["X", 33, "100101101011"], ["Y", 34, "110010110101"], ["Z", 35, "100110110101"], ["-", 36, "100101011011"], [".", 37, "110010101101"], [" ", 38, "100110101101"], ["$", 39, "100100100101"], ["/", 40, "100100101001"], ["+", 41, "100101001001"], ["%", 42, "101001001001"], ["*", NaN, "100101101101"]]; | ||
@@ -1142,4 +1142,4 @@ var code39Lookup = null; | ||
| var version = "2.0.1"; | ||
| var version = "2.2.0"; | ||
| export { drawBarcode, version }; |
+2
-2
@@ -328,3 +328,3 @@ /* | ||
| var code39Data = [["1", 1, "110100101011"], ["2", 2, "101100101011"], ["3", 3, "110110010101"], ["4", 4, "101001101011"], ["5", 5, "110100110101"], ["6", 6, "101100110101"], ["7", 7, "101001011011"], ["8", 8, "110100101101"], ["9", 9, "101100101101"], ["0", 0, "101001101101"], ["A", 10, "110101001011"], ["B", 11, "101101001011"], ["C", 12, "110110100101"], ["D", 13, "101011001011"], ["E", 14, "110101100101"], ["F", 15, "101101100101"], ["G", 16, "101010011011"], ["H", 17, "110101001101"], ["I", 18, "101101001101"], ["J", 19, "101011001101"], ["K", 20, "110101010011"], ["L", 21, "101101010011"], ["M", 22, "110110101001"], ["N", 23, "101011010011"], ["O", 24, "110101101001"], ["P", 25, "101101101001"], ["Q", 26, "101010110011"], ["R", 27, "110101011001"], ["S", 28, "101101011001"], ["T", 29, "101011011001"], ["U", 30, "110010101011"], ["V", 31, "100110101011"], ["W", 32, "110011010101"], ["X", 33, "100101101011"], ["Y", 34, "110010110101"], ["Z", 35, "100110110101"], ["-", 36, "100101011011"], [".", 37, "110010101101"], [" ", 38, "100110101101"], ["*", NaN, "100101101101"]]; | ||
| var code39Data = [["1", 1, "110100101011"], ["2", 2, "101100101011"], ["3", 3, "110110010101"], ["4", 4, "101001101011"], ["5", 5, "110100110101"], ["6", 6, "101100110101"], ["7", 7, "101001011011"], ["8", 8, "110100101101"], ["9", 9, "101100101101"], ["0", 0, "101001101101"], ["A", 10, "110101001011"], ["B", 11, "101101001011"], ["C", 12, "110110100101"], ["D", 13, "101011001011"], ["E", 14, "110101100101"], ["F", 15, "101101100101"], ["G", 16, "101010011011"], ["H", 17, "110101001101"], ["I", 18, "101101001101"], ["J", 19, "101011001101"], ["K", 20, "110101010011"], ["L", 21, "101101010011"], ["M", 22, "110110101001"], ["N", 23, "101011010011"], ["O", 24, "110101101001"], ["P", 25, "101101101001"], ["Q", 26, "101010110011"], ["R", 27, "110101011001"], ["S", 28, "101101011001"], ["T", 29, "101011011001"], ["U", 30, "110010101011"], ["V", 31, "100110101011"], ["W", 32, "110011010101"], ["X", 33, "100101101011"], ["Y", 34, "110010110101"], ["Z", 35, "100110110101"], ["-", 36, "100101011011"], [".", 37, "110010101101"], [" ", 38, "100110101101"], ["$", 39, "100100100101"], ["/", 40, "100100101001"], ["+", 41, "100101001001"], ["%", 42, "101001001001"], ["*", NaN, "100101101101"]]; | ||
@@ -1148,3 +1148,3 @@ var code39Lookup = null; | ||
| var version = "2.0.1"; | ||
| var version = "2.2.0"; | ||
@@ -1151,0 +1151,0 @@ exports.drawBarcode = drawBarcode; |
@@ -1,1 +0,1 @@ | ||
| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.bardcode={})}(this,function(e){"use strict";function t(e,t){if("number"!=typeof e)throw new Error("Expected "+t+" to be a number, got "+e)}function r(e,t){if("number"!=typeof e)throw new Error("Expected "+t+" to be a number, got "+e);if(e<=0)throw new Error("Expected "+t+" to be positive, got "+e)}function a(e){b();var t=new Array(1+e.length);t[0]="B0";for(var r=0,a=e.length;r<a;r++)t[1+r]=e[r];for(var n=0;n<t.length;n++){var o=t[n];u[o]&&!l[o]&&(t.splice(n,0,"SHIFT A"),n++)}var s=[],f=void 0;switch(t[0]){case"A0":f="A";break;case"B0":f="B";break;case"C0":f="C";break;default:throw new Error("Expected a starting character")}for(var p=void 0,v=0,R=0;R<t.length;R++){var w=t[R],g=void 0;switch(f){case"A":g=u[w];break;case"B":g=l[w];break;case"C":g=d[w]}if(!g)throw new Error("Invalid input (no such char '"+w+"' in mode "+f+")");var m=g[i],y=g[h];switch(v+=(R||1)*m,s.push({bits:y,char:w,humanReadable:null,_mode:f,_val:m}),p&&(f=p,p=null),w){case"CODE A":f="A";break;case"CODE B":f="B";break;case"CODE C":f="C";break;case"SHIFT A":p=f,f="A";break;case"SHIFT B":p=f,f="B"}}var E=v%103,k=c[E];s.push({bits:k[h],char:"CHECKSUM",humanReadable:!1,_val:E});var C=u.STOP;return s.push({bits:C[h],char:"STOP",humanReadable:!1,_val:C[i]}),{type:"bits",checksum:E,data:s}}var n={0:"1010100110",1:"1010110010",2:"1010010110",3:"1100101010",4:"1011010010",5:"1101010010",6:"1001010110",7:"1001011010",8:"1001101010",9:"1101001010","-":"1010011010",$:"1011001010",".":"11011011010","/":"11011010110",":":"11010110110","+":"10110110110"},o={C:"10100100110","*":"10100100110",B:"10010010110",N:"10010010110",D:"10100110010",E:"10100110010",A:"10110010010",T:"10110010010"},i=0,h=4,s=[[0," "," ","00","11011001100"],[1,"!","!","01","11001101100"],[2,'"','"',"02","11001100110"],[3,"#","#","03","10010011000"],[4,"$","$","04","10010001100"],[5," %"," %","05","10001001100"],[6,"&","&","06","10011001000"],[7,"'","'","07","10011000100"],[8,"(","(","08","10001100100"],[9,")",")","09","11001001000"],[10,"*","*","10","11001000100"],[11,"+","+","11","11000100100"],[12,", ",", ","12","10110011100"],[13,"-","-","13","10011011100"],[14,".",".","14","10011001110"],[15,"/","/","15","10111001100"],[16,"0","0","16","10011101100"],[17,"1","1","17","10011100110"],[18,"2","2","18","11001110010"],[19,"3","3","19","11001011100"],[20,"4","4","20","11001001110"],[21,"5","5","21","11011100100"],[22,"6","6","22","11001110100"],[23,"7","7","23","11101101110"],[24,"8","8","24","11101001100"],[25,"9","9","25","11100101100"],[26,":",":","26","11100100110"],[27,";",";","27","11101100100"],[28,"<","<","28","11100110100"],[29,"=","=","29","11100110010"],[30,">",">","30","11011011000"],[31,"?","?","31","11011000110"],[32,"@","@","32","11000110110"],[33,"A","A","33","10100011000"],[34,"B","B","34","10001011000"],[35,"C","C","35","10001000110"],[36,"D","D","36","10110001000"],[37,"E","E","37","10001101000"],[38,"F","F","38","10001100010"],[39,"G","G","39","11010001000"],[40,"H","H","40","11000101000"],[41,"I","I","41","11000100010"],[42,"J","J","42","10110111000"],[43,"K","K","43","10110001110"],[44,"L","L","44","10001101110"],[45,"M","M","45","10111011000"],[46,"N","N","46","10111000110"],[47,"O","O","47","10001110110"],[48,"P","P","48","11101110110"],[49,"Q","Q","49","11010001110"],[50,"R","R","50","11000101110"],[51,"S","S","51","11011101000"],[52,"T","T","52","11011100010"],[53,"U","U","53","11011101110"],[54,"V","V","54","11101011000"],[55,"W","W","55","11101000110"],[56,"X","X","56","11100010110"],[57,"Y","Y","57","11101101000"],[58,"Z","Z","58","11101100010"],[59,"[","[","59","11100011010"],[60,"\\","\\","60","11101111010"],[61,"]","]","61","11001000010"],[62,"^","^","62","11110001010"],[63,"_","_","63","10100110000"],[64,"\0","`","64","10100001100"],[65,"","a","65","10010110000"],[66,"","b","66","10010000110"],[67,"","c","67","10000101100"],[68,"","d","68","10000100110"],[69,"","e","69","10110010000"],[70,"","f","70","10110000100"],[71,"","g","71","10011010000"],[72,"\b","h","72","10011000010"],[73,"","i","73","10000110100"],[74,"\n","j","74","10000110010"],[75,"\v","k","75","11000010010"],[76,"\f","l","76","11001010000"],[77,"\r","m","77","11110111010"],[78,"\b","n","78","11000010100"],[79,"\t","o","79","10001111010"],[80,"","p","80","10100111100"],[81,"","q","81","10010111100"],[82,"","r","82","10010011110"],[83,"","s","83","10111100100"],[84,"","t","84","10011110100"],[85,"","u","85","10011110010"],[86,"","v","86","11110100100"],[87,"","w","87","11110010100"],[88,"","x","88","11110010010"],[89,"","y","89","11011011110"],[90,"","z","90","11011110110"],[91,"","{","91","11110110110"],[92,"","|","92","10101111000"],[93,"","}","93","10100011110"],[94,"","~","94","10001011110"],[95,"","","95","10111101000"],[96,"FNC 3","FNC 3","96","10111100010"],[97,"FNC 2","FNC 2","97","11110101000"],[98,"SHIFT B","SHIFT A","98","11110100010"],[99,"CODE C","CODE C","99","10111011110"],[100,"CODE B","FNC 4","CODE B","10111101110"],[101,"FNC 4","CODE A","CODE A","11101011110"],[102,"FNC 1","FNC 1","FNC 1","11110101110"],[103,"A0","A0","A0","11010000100"],[104,"B0","B0","B0","11010010000"],[105,"C0","C0","C0","11010011100"],[106,"STOP","STOP","STOP","1100011101011"]],c=null,u=null,l=null,d=null,b=function(){if(!c){c={},u={},l={},d={};for(var e=0;e<s.length;e++){var t=s[e],r=t[i],a=t[1],n=t[2],o=t[3];c[r]=t,u[a]=t,l[n]=t,d[o]=t}}},f=2,p=[["1",1,"110100101011"],["2",2,"101100101011"],["3",3,"110110010101"],["4",4,"101001101011"],["5",5,"110100110101"],["6",6,"101100110101"],["7",7,"101001011011"],["8",8,"110100101101"],["9",9,"101100101101"],["0",0,"101001101101"],["A",10,"110101001011"],["B",11,"101101001011"],["C",12,"110110100101"],["D",13,"101011001011"],["E",14,"110101100101"],["F",15,"101101100101"],["G",16,"101010011011"],["H",17,"110101001101"],["I",18,"101101001101"],["J",19,"101011001101"],["K",20,"110101010011"],["L",21,"101101010011"],["M",22,"110110101001"],["N",23,"101011010011"],["O",24,"110101101001"],["P",25,"101101101001"],["Q",26,"101010110011"],["R",27,"110101011001"],["S",28,"101101011001"],["T",29,"101011011001"],["U",30,"110010101011"],["V",31,"100110101011"],["W",32,"110011010101"],["X",33,"100101101011"],["Y",34,"110010110101"],["Z",35,"100110110101"],["-",36,"100101011011"],[".",37,"110010101101"],[" ",38,"100110101101"],["*",NaN,"100101101101"]],v=null,R=function(){v||(v={},p.forEach(function(e){var t=e[0];v[t]=e}))},w=0,g=1,m=2,y=[["0001101","0100111","1110010"],["0011001","0110011","1100110"],["0010011","0011011","1101100"],["0111101","0100001","1000010"],["0100011","0011101","1011100"],["0110001","0111001","1001110"],["0101111","0000101","1010000"],["0111011","0010001","1000100"],["0110111","0001001","1001000"],["0001011","0010111","1110100"]],E=[[0,0,1,1,0],[1,0,0,0,1],[0,1,0,0,1],[1,1,0,0,0],[0,0,1,0,1],[1,0,1,0,0],[0,1,1,0,0],[0,0,0,1,1],[1,0,0,1,0],[0,1,0,1,0]],k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},C=(function(){function e(e){this.value=e}function t(t){function r(n,o){try{var i=t[n](o),h=i.value;h instanceof e?Promise.resolve(h.value).then(function(e){r("next",e)},function(e){r("throw",e)}):a(i.done?"return":"normal",i.value)}catch(e){a("throw",e)}}function a(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?r(n.key,n.arg):o=null}var n,o;this._invoke=function(e,t){return new Promise(function(a,i){var h={key:e,arg:t,resolve:a,reject:i,next:null};o?o=o.next=h:(n=o=h,r(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),{type:"Code 128",hasChecksum:!1,x:0,y:0,moduleWidth:2.892,height:90.72,horizontalAlign:"left",verticalAlign:"top",quietZoneSize:10,angle:0,maxWidth:1/0,width:NaN}),L=function(e,t){for(var r in t)void 0===e[r]&&(e[r]=t[r])};e.drawBarcode=function(e,i,h){if("object"!==(void 0===e?"undefined":k(e))&&"path"!==e&&"svg"!==e)throw new Error("drawBarcode: expected `g' to be an object or 'path' or 'svg'.");if(!i)throw new Error("drawBarcode: missing required parameter `text'.");"object"!==(void 0===h?"undefined":k(h))&&(h={}),L(h,C),function(e){(function(e,t){if("boolean"!=typeof e)throw new Error("Expected "+t+" to be a boolean, got "+e)})(e.hasChecksum,"options.hasChecksum"),t(e.x,"options.x"),t(e.y,"options.y"),function(e){switch(e){case"left":case"center":case"right":return;default:throw new Error('Unexpected horizontalAlign (acceptable values are "left", "center", and "right"); got '+e)}}(e.horizontalAlign),function(e){switch(e){case"top":case"middle":case"bottom":return;default:throw new Error('Unexpected verticalAlign (acceptable values are "top", "middle", and "bottom"); got '+e)}}(e.verticalAlign),r(e.height,"options.height"),r(e.moduleWidth,"options.moduleWidth"),function(e,t){if("number"!=typeof e)throw new Error("Expected "+t+" to be a number, got "+e);if(e<0)throw new Error("Expected "+t+" to be non-negative, got "+e)}(e.quietZoneSize,"options.quietZoneSize"),t(e.angle,"options.angle"),r(e.maxWidth,"options.maxWidth"),isNaN(e.width)||r(e.width,"options.width")}(h);var s=void 0;switch(h.type){case"Codabar":s=function(e){if(!/^[C\*BNDEAT]?[-:0-9\$\.\/\+]*[C\*BNDEAT]?$/.test(e))throw new Error('Cannot encode "'+e+'" in codabar.');0===e.length&&(e="AA");var t=!!o[e[0]],r=!!o[e[e.length-1]];if(1===e.length&&t)throw new Error('Cannot encode "'+e+"\" as codabar: it's just a start/stop character");if(t^r)throw new Error('Cannot encode "'+e+'" as codabar: must give both start and stop characters or neither start nor stop');var a=[];t||(e="A"+e+"A");for(var i=0;i<e.length;i++){var h=e[i];0!==i&&i!==e.length-1?a.push({char:h,humanReadable:!0,bits:n[h]}):a.push({char:h,humanReadable:!1,bits:o[h]})}return{type:"bits",data:a}}(i);break;case"Code 128":s=a(i);break;case"GS1 128":var c=[];c.push("FNC 1");for(var u=0;u<i.length;u++)c.push(i[u]);s=a(c);break;case"Code 39":s=function(e,t){R(),t=t||!1,e||(e=""),e="*"+e+"*";for(var r=[],a=0;a<e.length;a++){0!==a&&r.push({char:"",bits:"0",humanReadable:!1});var n=e[a],o=v[n];if(!o)throw new Error("Cannot encode code 39 barcode: invalid char: "+n);var i=o[f];r.push({char:n,bits:i,humanReadable:!0})}return{type:"bits",data:r}}(i);break;case"ITF":s=function(e){e.length%2==1&&(e="0"+e);for(var t=0,r=e.length;t<r;t++){var a=e[t];if(a<"0"||a>"9")throw new Error("ITF can only encode numbers.")}var n=[];n.push({char:"START",bits:"1010",humanReadable:!1});for(var o=0;o<e.length;o+=2){for(var i=e[o],h=e[o+1],s=i-"0",c=h-"0",u="",l=0;l<5;l++)u+=0===E[s][l]?"1":"11",u+=0===E[c][l]?"0":"00";n.push({char:i+h,bits:u,humanReadable:!0})}return n.push({char:"STOP",bits:"1101",humanReadable:!1}),{type:"bits",data:n}}(i);break;case"FIM":s=function(e){if(!/^[ABCD]$/.test(e))throw new Error("FIM can only encode 'A', 'B', 'C', or 'D'");var t=void 0;switch(e){case"A":t="110010011";break;case"B":t="101101101";break;case"C":t="110101011";break;case"D":t="111010111"}return{type:"bits",data:[{char:e,humanReadable:!1,bits:t}]}}(i);break;case"EAN-8":case"EAN-13":case"UPC-A":var l=void 0;if("EAN-8"===h.type&&(l=7),"EAN-13"===h.type&&(l=12),"UPC-A"===h.type&&(l=11),h.hasChecksum&&(l+=1),l!==i.length)throw new Error(h.type+" must be of length "+l);s=function(e,t){if(!/^\d+$/.test(e))throw new Error("EAN can only encode numbers.");var r=void 0;t&&(r=parseInt(e.substr(e.length-1,1),10),e=e.substr(0,e.length-1));for(var a=e.length,n=0,o=0;o<a;o++){var i=e[o];n+=((a-o)%2==1?3:1)*(i-"0")}var h=10*Math.round(n/10),s=h-n;if(s<0&&(s=h+10-n),t&&s!==r)throw new Error("Invalid checksum.");var c=[],u=void 0;switch((e+=s).length){case 8:u="LLLLRRRR";break;case 12:u="LLLLLLRRRRRR";break;case 13:switch(e[0]){case"0":u="LLLLLLRRRRRR";break;case"1":u="LLGLGGRRRRRR";break;case"2":u="LLGGLGRRRRRR";break;case"3":u="LLGGGLRRRRRR";break;case"4":u="LGLLGGRRRRRR";break;case"5":u="LGGLLGRRRRRR";break;case"6":u="LGGGLLRRRRRR";break;case"7":u="LGLGLGRRRRRR";break;case"8":u="LGLGGLRRRRRR";break;case"9":u="LGGLGLRRRRRR"}c.push({char:e[0],humanReadable:!0,bits:""}),e=e.slice(1);break;default:throw new Error("Don't know how to make EAN with that length.")}c.push({char:"START",humanReadable:!1,bits:"101"});for(var l=0;l<e.length;l++){l===e.length/2&&c.push({char:"CENTER",humanReadable:!1,bits:"01010"});var d=e[l]-"0",b=u[l],f="L"===b?w:"G"===b?g:m,p=y[d][f];c.push({char:e[l],humanReadable:!0,bits:p})}return c.push({char:"END",humanReadable:!1,bits:"101"}),{type:"bits",checksum:s,data:c}}(i,h.hasChecksum);break;default:throw new Error("Unrecognized barcode type: "+h.type)}switch(s.type){case"bits":return function(e,t,r){return"path"===e?function(e,t){var r=t.data.map(function(e){return e.bits}).join(""),a=r.length+2*e.quietZoneSize,n=void 0;isNaN(e.width)?a*(n=e.moduleWidth)>e.maxWidth&&(n=e.maxWidth/a):n=e.width/a;for(var o=e.height,i=[],h=e.quietZoneSize*n,s=0;s<r.length;)if("1"===r[s]){for(var c=1;s<r.length&&"1"===r[++s];)c++;var u=c*n;i.push("M "+h.toFixed(3)+",0"),i.push("l "+u+",0"),i.push("l 0,"+o),i.push("l "+(-u).toFixed(3)+",0"),i.push("Z"),h+=u}else{for(var l=1;s<r.length&&"0"===r[++s];)l++;h+=l*n}return i.join(" ")}(t,r):"svg"===e?function(e,t){var r=t.data.map(function(e){return e.bits}).join(""),a=r.length+2*e.quietZoneSize,n=void 0,o=void 0;isNaN(e.width)?(o=a*(n=e.moduleWidth))>e.maxWidth&&(n=(o=e.maxWidth)/a):n=(o=e.width)/a;var i=e.height,h=[],s=["xmlns='http://www.w3.org/2000/svg'","width='"+o.toFixed(3)+"'","height='"+i+"'","fill='black'"].join(" ");h.push("<svg "+s+">");for(var c=e.quietZoneSize*n,u=0;u<r.length;)if("1"===r[u]){for(var l=1;u<r.length&&"1"===r[++u];)l++;var d=l*n,b=["width='"+d+"'","height='"+i+"'","x='"+c.toFixed(3)+"'","y='0'"].join(" ");h.push("<rect "+b+" />"),c+=d}else{for(var f=1;u<r.length&&"0"===r[++u];)f++;c+=f*n}return h.push("</svg>"),h.join("\n")}(t,r):function(e,t,r){var a=r.data.map(function(e){return e.bits}).join("");e.save();var n=a.length+2*t.quietZoneSize,o=void 0,i=void 0;isNaN(t.width)?(i=n*(o=t.moduleWidth))>t.maxWidth&&(o=(i=t.maxWidth)/n):o=(i=t.width)/n;var h=t.height;e.translate(t.x,t.y);var s=t.angle*Math.PI/180,c=Math.cos(s),u=Math.sin(s),l=[0,i*c,i*c-h*u,-h*u],d=[0,i*u,i*u+h*c,h*c],b=Math.min.apply(this,l),f=Math.min.apply(this,d),p=Math.max.apply(this,l),v=Math.max.apply(this,d);switch(t.horizontalAlign){case"left":e.translate(-b,0);break;case"center":e.translate(-(i/2*c-h/2*u),0);break;case"right":e.translate(-p,0)}switch(t.verticalAlign){case"top":e.translate(0,-f);break;case"middle":e.translate(0,-(i/2*u+h/2*c));break;case"bottom":e.translate(0,-v)}e.rotate(s),e.translate(t.quietZoneSize*o,0),e.fillStyle="black";for(var R=0;R<a.length;)if("1"===a[R]){for(var w=1;R<a.length&&"1"===a[++R];)w++;var g=w*o;e.fillRect(0,0,g,h),e.translate(g,0)}else{for(var m=1;R<a.length&&"0"===a[++R];)m++;var y=m*o;e.translate(y,0)}return e.restore(),{barcodeWidth:i,barcodeHeight:h,bbox:{x:b,y:f,width:p-b,height:v-f}}}(e,t,r)}(e,h,s);default:throw new Error("Unrecognized encoded barcode type: "+s.type)}},e.version="2.0.1",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.bardcode={})}(this,function(e){"use strict";function t(e,t){if("number"!=typeof e)throw new Error("Expected "+t+" to be a number, got "+e)}function r(e,t){if("number"!=typeof e)throw new Error("Expected "+t+" to be a number, got "+e);if(e<=0)throw new Error("Expected "+t+" to be positive, got "+e)}function a(e){b();var t=new Array(1+e.length);t[0]="B0";for(var r=0,a=e.length;r<a;r++)t[1+r]=e[r];for(var n=0;n<t.length;n++){var o=t[n];u[o]&&!l[o]&&(t.splice(n,0,"SHIFT A"),n++)}var s=[],f=void 0;switch(t[0]){case"A0":f="A";break;case"B0":f="B";break;case"C0":f="C";break;default:throw new Error("Expected a starting character")}for(var p=void 0,v=0,R=0;R<t.length;R++){var w=t[R],g=void 0;switch(f){case"A":g=u[w];break;case"B":g=l[w];break;case"C":g=d[w]}if(!g)throw new Error("Invalid input (no such char '"+w+"' in mode "+f+")");var m=g[i],y=g[h];switch(v+=(R||1)*m,s.push({bits:y,char:w,humanReadable:null,_mode:f,_val:m}),p&&(f=p,p=null),w){case"CODE A":f="A";break;case"CODE B":f="B";break;case"CODE C":f="C";break;case"SHIFT A":p=f,f="A";break;case"SHIFT B":p=f,f="B"}}var E=v%103,k=c[E];s.push({bits:k[h],char:"CHECKSUM",humanReadable:!1,_val:E});var C=u.STOP;return s.push({bits:C[h],char:"STOP",humanReadable:!1,_val:C[i]}),{type:"bits",checksum:E,data:s}}var n={0:"1010100110",1:"1010110010",2:"1010010110",3:"1100101010",4:"1011010010",5:"1101010010",6:"1001010110",7:"1001011010",8:"1001101010",9:"1101001010","-":"1010011010",$:"1011001010",".":"11011011010","/":"11011010110",":":"11010110110","+":"10110110110"},o={C:"10100100110","*":"10100100110",B:"10010010110",N:"10010010110",D:"10100110010",E:"10100110010",A:"10110010010",T:"10110010010"},i=0,h=4,s=[[0," "," ","00","11011001100"],[1,"!","!","01","11001101100"],[2,'"','"',"02","11001100110"],[3,"#","#","03","10010011000"],[4,"$","$","04","10010001100"],[5," %"," %","05","10001001100"],[6,"&","&","06","10011001000"],[7,"'","'","07","10011000100"],[8,"(","(","08","10001100100"],[9,")",")","09","11001001000"],[10,"*","*","10","11001000100"],[11,"+","+","11","11000100100"],[12,", ",", ","12","10110011100"],[13,"-","-","13","10011011100"],[14,".",".","14","10011001110"],[15,"/","/","15","10111001100"],[16,"0","0","16","10011101100"],[17,"1","1","17","10011100110"],[18,"2","2","18","11001110010"],[19,"3","3","19","11001011100"],[20,"4","4","20","11001001110"],[21,"5","5","21","11011100100"],[22,"6","6","22","11001110100"],[23,"7","7","23","11101101110"],[24,"8","8","24","11101001100"],[25,"9","9","25","11100101100"],[26,":",":","26","11100100110"],[27,";",";","27","11101100100"],[28,"<","<","28","11100110100"],[29,"=","=","29","11100110010"],[30,">",">","30","11011011000"],[31,"?","?","31","11011000110"],[32,"@","@","32","11000110110"],[33,"A","A","33","10100011000"],[34,"B","B","34","10001011000"],[35,"C","C","35","10001000110"],[36,"D","D","36","10110001000"],[37,"E","E","37","10001101000"],[38,"F","F","38","10001100010"],[39,"G","G","39","11010001000"],[40,"H","H","40","11000101000"],[41,"I","I","41","11000100010"],[42,"J","J","42","10110111000"],[43,"K","K","43","10110001110"],[44,"L","L","44","10001101110"],[45,"M","M","45","10111011000"],[46,"N","N","46","10111000110"],[47,"O","O","47","10001110110"],[48,"P","P","48","11101110110"],[49,"Q","Q","49","11010001110"],[50,"R","R","50","11000101110"],[51,"S","S","51","11011101000"],[52,"T","T","52","11011100010"],[53,"U","U","53","11011101110"],[54,"V","V","54","11101011000"],[55,"W","W","55","11101000110"],[56,"X","X","56","11100010110"],[57,"Y","Y","57","11101101000"],[58,"Z","Z","58","11101100010"],[59,"[","[","59","11100011010"],[60,"\\","\\","60","11101111010"],[61,"]","]","61","11001000010"],[62,"^","^","62","11110001010"],[63,"_","_","63","10100110000"],[64,"\0","`","64","10100001100"],[65,"","a","65","10010110000"],[66,"","b","66","10010000110"],[67,"","c","67","10000101100"],[68,"","d","68","10000100110"],[69,"","e","69","10110010000"],[70,"","f","70","10110000100"],[71,"","g","71","10011010000"],[72,"\b","h","72","10011000010"],[73,"","i","73","10000110100"],[74,"\n","j","74","10000110010"],[75,"\v","k","75","11000010010"],[76,"\f","l","76","11001010000"],[77,"\r","m","77","11110111010"],[78,"\b","n","78","11000010100"],[79,"\t","o","79","10001111010"],[80,"","p","80","10100111100"],[81,"","q","81","10010111100"],[82,"","r","82","10010011110"],[83,"","s","83","10111100100"],[84,"","t","84","10011110100"],[85,"","u","85","10011110010"],[86,"","v","86","11110100100"],[87,"","w","87","11110010100"],[88,"","x","88","11110010010"],[89,"","y","89","11011011110"],[90,"","z","90","11011110110"],[91,"","{","91","11110110110"],[92,"","|","92","10101111000"],[93,"","}","93","10100011110"],[94,"","~","94","10001011110"],[95,"","","95","10111101000"],[96,"FNC 3","FNC 3","96","10111100010"],[97,"FNC 2","FNC 2","97","11110101000"],[98,"SHIFT B","SHIFT A","98","11110100010"],[99,"CODE C","CODE C","99","10111011110"],[100,"CODE B","FNC 4","CODE B","10111101110"],[101,"FNC 4","CODE A","CODE A","11101011110"],[102,"FNC 1","FNC 1","FNC 1","11110101110"],[103,"A0","A0","A0","11010000100"],[104,"B0","B0","B0","11010010000"],[105,"C0","C0","C0","11010011100"],[106,"STOP","STOP","STOP","1100011101011"]],c=null,u=null,l=null,d=null,b=function(){if(!c){c={},u={},l={},d={};for(var e=0;e<s.length;e++){var t=s[e],r=t[i],a=t[1],n=t[2],o=t[3];c[r]=t,u[a]=t,l[n]=t,d[o]=t}}},f=2,p=[["1",1,"110100101011"],["2",2,"101100101011"],["3",3,"110110010101"],["4",4,"101001101011"],["5",5,"110100110101"],["6",6,"101100110101"],["7",7,"101001011011"],["8",8,"110100101101"],["9",9,"101100101101"],["0",0,"101001101101"],["A",10,"110101001011"],["B",11,"101101001011"],["C",12,"110110100101"],["D",13,"101011001011"],["E",14,"110101100101"],["F",15,"101101100101"],["G",16,"101010011011"],["H",17,"110101001101"],["I",18,"101101001101"],["J",19,"101011001101"],["K",20,"110101010011"],["L",21,"101101010011"],["M",22,"110110101001"],["N",23,"101011010011"],["O",24,"110101101001"],["P",25,"101101101001"],["Q",26,"101010110011"],["R",27,"110101011001"],["S",28,"101101011001"],["T",29,"101011011001"],["U",30,"110010101011"],["V",31,"100110101011"],["W",32,"110011010101"],["X",33,"100101101011"],["Y",34,"110010110101"],["Z",35,"100110110101"],["-",36,"100101011011"],[".",37,"110010101101"],[" ",38,"100110101101"],["$",39,"100100100101"],["/",40,"100100101001"],["+",41,"100101001001"],["%",42,"101001001001"],["*",NaN,"100101101101"]],v=null,R=function(){v||(v={},p.forEach(function(e){var t=e[0];v[t]=e}))},w=0,g=1,m=2,y=[["0001101","0100111","1110010"],["0011001","0110011","1100110"],["0010011","0011011","1101100"],["0111101","0100001","1000010"],["0100011","0011101","1011100"],["0110001","0111001","1001110"],["0101111","0000101","1010000"],["0111011","0010001","1000100"],["0110111","0001001","1001000"],["0001011","0010111","1110100"]],E=[[0,0,1,1,0],[1,0,0,0,1],[0,1,0,0,1],[1,1,0,0,0],[0,0,1,0,1],[1,0,1,0,0],[0,1,1,0,0],[0,0,0,1,1],[1,0,0,1,0],[0,1,0,1,0]],k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},C=(function(){function e(e){this.value=e}function t(t){function r(n,o){try{var i=t[n](o),h=i.value;h instanceof e?Promise.resolve(h.value).then(function(e){r("next",e)},function(e){r("throw",e)}):a(i.done?"return":"normal",i.value)}catch(e){a("throw",e)}}function a(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?r(n.key,n.arg):o=null}var n,o;this._invoke=function(e,t){return new Promise(function(a,i){var h={key:e,arg:t,resolve:a,reject:i,next:null};o?o=o.next=h:(n=o=h,r(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),{type:"Code 128",hasChecksum:!1,x:0,y:0,moduleWidth:2.892,height:90.72,horizontalAlign:"left",verticalAlign:"top",quietZoneSize:10,angle:0,maxWidth:1/0,width:NaN}),L=function(e,t){for(var r in t)void 0===e[r]&&(e[r]=t[r])};e.drawBarcode=function(e,i,h){if("object"!==(void 0===e?"undefined":k(e))&&"path"!==e&&"svg"!==e)throw new Error("drawBarcode: expected `g' to be an object or 'path' or 'svg'.");if(!i)throw new Error("drawBarcode: missing required parameter `text'.");"object"!==(void 0===h?"undefined":k(h))&&(h={}),L(h,C),function(e){(function(e,t){if("boolean"!=typeof e)throw new Error("Expected "+t+" to be a boolean, got "+e)})(e.hasChecksum,"options.hasChecksum"),t(e.x,"options.x"),t(e.y,"options.y"),function(e){switch(e){case"left":case"center":case"right":return;default:throw new Error('Unexpected horizontalAlign (acceptable values are "left", "center", and "right"); got '+e)}}(e.horizontalAlign),function(e){switch(e){case"top":case"middle":case"bottom":return;default:throw new Error('Unexpected verticalAlign (acceptable values are "top", "middle", and "bottom"); got '+e)}}(e.verticalAlign),r(e.height,"options.height"),r(e.moduleWidth,"options.moduleWidth"),function(e,t){if("number"!=typeof e)throw new Error("Expected "+t+" to be a number, got "+e);if(e<0)throw new Error("Expected "+t+" to be non-negative, got "+e)}(e.quietZoneSize,"options.quietZoneSize"),t(e.angle,"options.angle"),r(e.maxWidth,"options.maxWidth"),isNaN(e.width)||r(e.width,"options.width")}(h);var s=void 0;switch(h.type){case"Codabar":s=function(e){if(!/^[C\*BNDEAT]?[-:0-9\$\.\/\+]*[C\*BNDEAT]?$/.test(e))throw new Error('Cannot encode "'+e+'" in codabar.');0===e.length&&(e="AA");var t=!!o[e[0]],r=!!o[e[e.length-1]];if(1===e.length&&t)throw new Error('Cannot encode "'+e+"\" as codabar: it's just a start/stop character");if(t^r)throw new Error('Cannot encode "'+e+'" as codabar: must give both start and stop characters or neither start nor stop');var a=[];t||(e="A"+e+"A");for(var i=0;i<e.length;i++){var h=e[i];0!==i&&i!==e.length-1?a.push({char:h,humanReadable:!0,bits:n[h]}):a.push({char:h,humanReadable:!1,bits:o[h]})}return{type:"bits",data:a}}(i);break;case"Code 128":s=a(i);break;case"GS1 128":var c=[];c.push("FNC 1");for(var u=0;u<i.length;u++)c.push(i[u]);s=a(c);break;case"Code 39":s=function(e,t){R(),t=t||!1,e||(e=""),e="*"+e+"*";for(var r=[],a=0;a<e.length;a++){0!==a&&r.push({char:"",bits:"0",humanReadable:!1});var n=e[a],o=v[n];if(!o)throw new Error("Cannot encode code 39 barcode: invalid char: "+n);var i=o[f];r.push({char:n,bits:i,humanReadable:!0})}return{type:"bits",data:r}}(i);break;case"ITF":s=function(e){e.length%2==1&&(e="0"+e);for(var t=0,r=e.length;t<r;t++){var a=e[t];if(a<"0"||a>"9")throw new Error("ITF can only encode numbers.")}var n=[];n.push({char:"START",bits:"1010",humanReadable:!1});for(var o=0;o<e.length;o+=2){for(var i=e[o],h=e[o+1],s=i-"0",c=h-"0",u="",l=0;l<5;l++)u+=0===E[s][l]?"1":"11",u+=0===E[c][l]?"0":"00";n.push({char:i+h,bits:u,humanReadable:!0})}return n.push({char:"STOP",bits:"1101",humanReadable:!1}),{type:"bits",data:n}}(i);break;case"FIM":s=function(e){if(!/^[ABCD]$/.test(e))throw new Error("FIM can only encode 'A', 'B', 'C', or 'D'");var t=void 0;switch(e){case"A":t="110010011";break;case"B":t="101101101";break;case"C":t="110101011";break;case"D":t="111010111"}return{type:"bits",data:[{char:e,humanReadable:!1,bits:t}]}}(i);break;case"EAN-8":case"EAN-13":case"UPC-A":var l=void 0;if("EAN-8"===h.type&&(l=7),"EAN-13"===h.type&&(l=12),"UPC-A"===h.type&&(l=11),h.hasChecksum&&(l+=1),l!==i.length)throw new Error(h.type+" must be of length "+l);s=function(e,t){if(!/^\d+$/.test(e))throw new Error("EAN can only encode numbers.");var r=void 0;t&&(r=parseInt(e.substr(e.length-1,1),10),e=e.substr(0,e.length-1));for(var a=e.length,n=0,o=0;o<a;o++){var i=e[o];n+=((a-o)%2==1?3:1)*(i-"0")}var h=10*Math.round(n/10),s=h-n;if(s<0&&(s=h+10-n),t&&s!==r)throw new Error("Invalid checksum.");var c=[],u=void 0;switch((e+=s).length){case 8:u="LLLLRRRR";break;case 12:u="LLLLLLRRRRRR";break;case 13:switch(e[0]){case"0":u="LLLLLLRRRRRR";break;case"1":u="LLGLGGRRRRRR";break;case"2":u="LLGGLGRRRRRR";break;case"3":u="LLGGGLRRRRRR";break;case"4":u="LGLLGGRRRRRR";break;case"5":u="LGGLLGRRRRRR";break;case"6":u="LGGGLLRRRRRR";break;case"7":u="LGLGLGRRRRRR";break;case"8":u="LGLGGLRRRRRR";break;case"9":u="LGGLGLRRRRRR"}c.push({char:e[0],humanReadable:!0,bits:""}),e=e.slice(1);break;default:throw new Error("Don't know how to make EAN with that length.")}c.push({char:"START",humanReadable:!1,bits:"101"});for(var l=0;l<e.length;l++){l===e.length/2&&c.push({char:"CENTER",humanReadable:!1,bits:"01010"});var d=e[l]-"0",b=u[l],f="L"===b?w:"G"===b?g:m,p=y[d][f];c.push({char:e[l],humanReadable:!0,bits:p})}return c.push({char:"END",humanReadable:!1,bits:"101"}),{type:"bits",checksum:s,data:c}}(i,h.hasChecksum);break;default:throw new Error("Unrecognized barcode type: "+h.type)}switch(s.type){case"bits":return function(e,t,r){return"path"===e?function(e,t){var r=t.data.map(function(e){return e.bits}).join(""),a=r.length+2*e.quietZoneSize,n=void 0;isNaN(e.width)?a*(n=e.moduleWidth)>e.maxWidth&&(n=e.maxWidth/a):n=e.width/a;for(var o=e.height,i=[],h=e.quietZoneSize*n,s=0;s<r.length;)if("1"===r[s]){for(var c=1;s<r.length&&"1"===r[++s];)c++;var u=c*n;i.push("M "+h.toFixed(3)+",0"),i.push("l "+u+",0"),i.push("l 0,"+o),i.push("l "+(-u).toFixed(3)+",0"),i.push("Z"),h+=u}else{for(var l=1;s<r.length&&"0"===r[++s];)l++;h+=l*n}return i.join(" ")}(t,r):"svg"===e?function(e,t){var r=t.data.map(function(e){return e.bits}).join(""),a=r.length+2*e.quietZoneSize,n=void 0,o=void 0;isNaN(e.width)?(o=a*(n=e.moduleWidth))>e.maxWidth&&(n=(o=e.maxWidth)/a):n=(o=e.width)/a;var i=e.height,h=[],s=["xmlns='http://www.w3.org/2000/svg'","width='"+o.toFixed(3)+"'","height='"+i+"'","fill='black'"].join(" ");h.push("<svg "+s+">");for(var c=e.quietZoneSize*n,u=0;u<r.length;)if("1"===r[u]){for(var l=1;u<r.length&&"1"===r[++u];)l++;var d=l*n,b=["width='"+d+"'","height='"+i+"'","x='"+c.toFixed(3)+"'","y='0'"].join(" ");h.push("<rect "+b+" />"),c+=d}else{for(var f=1;u<r.length&&"0"===r[++u];)f++;c+=f*n}return h.push("</svg>"),h.join("\n")}(t,r):function(e,t,r){var a=r.data.map(function(e){return e.bits}).join("");e.save();var n=a.length+2*t.quietZoneSize,o=void 0,i=void 0;isNaN(t.width)?(i=n*(o=t.moduleWidth))>t.maxWidth&&(o=(i=t.maxWidth)/n):o=(i=t.width)/n;var h=t.height;e.translate(t.x,t.y);var s=t.angle*Math.PI/180,c=Math.cos(s),u=Math.sin(s),l=[0,i*c,i*c-h*u,-h*u],d=[0,i*u,i*u+h*c,h*c],b=Math.min.apply(this,l),f=Math.min.apply(this,d),p=Math.max.apply(this,l),v=Math.max.apply(this,d);switch(t.horizontalAlign){case"left":e.translate(-b,0);break;case"center":e.translate(-(i/2*c-h/2*u),0);break;case"right":e.translate(-p,0)}switch(t.verticalAlign){case"top":e.translate(0,-f);break;case"middle":e.translate(0,-(i/2*u+h/2*c));break;case"bottom":e.translate(0,-v)}e.rotate(s),e.translate(t.quietZoneSize*o,0),e.fillStyle="black";for(var R=0;R<a.length;)if("1"===a[R]){for(var w=1;R<a.length&&"1"===a[++R];)w++;var g=w*o;e.fillRect(0,0,g,h),e.translate(g,0)}else{for(var m=1;R<a.length&&"0"===a[++R];)m++;var y=m*o;e.translate(y,0)}return e.restore(),{barcodeWidth:i,barcodeHeight:h,bbox:{x:b,y:f,width:p-b,height:v-f}}}(e,t,r)}(e,h,s);default:throw new Error("Unrecognized encoded barcode type: "+s.type)}},e.version="2.2.0",Object.defineProperty(e,"__esModule",{value:!0})}); |
+1
-1
| { | ||
| "name": "bardcode", | ||
| "version": "2.1.0", | ||
| "version": "2.2.0", | ||
| "description": "Draw 1-D barcodes to Canvases", | ||
@@ -5,0 +5,0 @@ "files": ["dist"], |
+1
-0
@@ -140,2 +140,3 @@ Render 1-D barcodes to canvas, svg, or path. Supports Code 128, 3 of 9, 2 of 5, EAN, and more. | ||
| * Tom S. | ||
| * [I Putu Susila](https://github.com/ipsusila) | ||
@@ -142,0 +143,0 @@ ## License |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
94313
0.46%1978
0.1%145
0.69%