ll-package
Version:
2 lines (1 loc) • 2.89 kB
JavaScript
"use strict";const o=require("../../../../../_virtual/UPC.js");require("./encoder.js");require("../Barcode.js");const h=require("../../../../../_virtual/encoder.js"),s=require("../../../../../_virtual/Barcode.js");Object.defineProperty(o.__exports,"__esModule",{value:!0});var d=function(){function n(t,i){for(var e=0;e<i.length;e++){var r=i[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(t,i,e){return i&&n(t.prototype,i),e&&n(t,e),t}}();o.__exports.checksum=u;var c=h.__exports,a=f(c),l=s.__exports,_=f(l);function f(n){return n&&n.__esModule?n:{default:n}}function g(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function p(n,t){if(!n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&(typeof t=="object"||typeof t=="function")?t:n}function y(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof t);n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(n,t):n.__proto__=t)}var v=function(n){y(t,n);function t(i,e){g(this,t),i.search(/^[0-9]{11}$/)!==-1&&(i+=u(i));var r=p(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,i,e));return r.displayValue=e.displayValue,e.fontSize>e.width*10?r.fontSize=e.width*10:r.fontSize=e.fontSize,r.guardHeight=e.height+r.fontSize/2+e.textMargin,r}return d(t,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==u(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var e="";return e+="101",e+=(0,a.default)(this.data.substr(0,6),"LLLLLL"),e+="01010",e+=(0,a.default)(this.data.substr(6,6),"RRRRRR"),e+="101",{data:e,text:this.text}}},{key:"guardedEncoding",value:function(){var e=[];return this.displayValue&&e.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),e.push({data:"101"+(0,a.default)(this.data[0],"L"),options:{height:this.guardHeight}}),e.push({data:(0,a.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),e.push({data:"01010",options:{height:this.guardHeight}}),e.push({data:(0,a.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),e.push({data:(0,a.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&e.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),e}}]),t}(_.default);function u(n){var t=0,i;for(i=1;i<11;i+=2)t+=parseInt(n[i]);for(i=0;i<11;i+=2)t+=parseInt(n[i])*3;return(10-t%10)%10}o.__exports.default=v;