yh-hiprint 2.3.5 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/HiprintDesigner.vue +494 -86
  2. package/hooks/useHiprint.js +48 -27
  3. package/libs/jquery.js +1 -0
  4. package/libs/jsbarcode/JsBarcode.js +225 -251
  5. package/libs/jsbarcode/barcodes/Barcode.js +9 -17
  6. package/libs/jsbarcode/barcodes/CODE128/CODE128.js +93 -133
  7. package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +10 -38
  8. package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +10 -38
  9. package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +10 -38
  10. package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +10 -36
  11. package/libs/jsbarcode/barcodes/CODE128/auto.js +32 -37
  12. package/libs/jsbarcode/barcodes/CODE128/constants.js +47 -30
  13. package/libs/jsbarcode/barcodes/CODE128/index.js +5 -28
  14. package/libs/jsbarcode/barcodes/CODE39/index.js +61 -61
  15. package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +58 -78
  16. package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +66 -95
  17. package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +22 -50
  18. package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +29 -54
  19. package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +42 -66
  20. package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +92 -125
  21. package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +134 -142
  22. package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +32 -21
  23. package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +11 -18
  24. package/libs/jsbarcode/barcodes/EAN_UPC/index.js +8 -39
  25. package/libs/jsbarcode/barcodes/GenericBarcode/index.js +16 -49
  26. package/libs/jsbarcode/barcodes/ITF/ITF.js +31 -63
  27. package/libs/jsbarcode/barcodes/ITF/ITF14.js +18 -40
  28. package/libs/jsbarcode/barcodes/ITF/constants.js +6 -8
  29. package/libs/jsbarcode/barcodes/ITF/index.js +3 -18
  30. package/libs/jsbarcode/barcodes/MSI/MSI.js +31 -57
  31. package/libs/jsbarcode/barcodes/MSI/MSI10.js +7 -30
  32. package/libs/jsbarcode/barcodes/MSI/MSI1010.js +10 -33
  33. package/libs/jsbarcode/barcodes/MSI/MSI11.js +7 -30
  34. package/libs/jsbarcode/barcodes/MSI/MSI1110.js +10 -33
  35. package/libs/jsbarcode/barcodes/MSI/checksums.js +11 -17
  36. package/libs/jsbarcode/barcodes/MSI/index.js +6 -33
  37. package/libs/jsbarcode/barcodes/codabar/index.js +49 -78
  38. package/libs/jsbarcode/barcodes/index.js +20 -33
  39. package/libs/jsbarcode/barcodes/pharmacode/index.js +32 -62
  40. package/libs/jsbarcode/exceptions/ErrorHandler.js +28 -43
  41. package/libs/jsbarcode/exceptions/exceptions.js +21 -59
  42. package/libs/jsbarcode/help/fixOptions.js +3 -9
  43. package/libs/jsbarcode/help/getOptionsFromElement.js +10 -23
  44. package/libs/jsbarcode/help/getRenderProperties.js +63 -69
  45. package/libs/jsbarcode/help/linearizeEncodings.js +8 -13
  46. package/libs/jsbarcode/help/merge.js +1 -11
  47. package/libs/jsbarcode/help/optionsFromStrings.js +19 -15
  48. package/libs/jsbarcode/options/defaults.js +2 -7
  49. package/libs/jsbarcode/renderers/canvas.js +106 -127
  50. package/libs/jsbarcode/renderers/index.js +4 -20
  51. package/libs/jsbarcode/renderers/object.js +7 -23
  52. package/libs/jsbarcode/renderers/shared.js +32 -39
  53. package/libs/jsbarcode/renderers/svg.js +136 -154
  54. package/package.json +1 -1
  55. package/libs/jsbarcode/barcodes/index.tmp.js +0 -33
@@ -1,176 +1,168 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- var _encoder = require('./encoder');
10
-
11
- var _encoder2 = _interopRequireDefault(_encoder);
12
-
13
- var _Barcode2 = require('../Barcode.js');
14
-
15
- var _Barcode3 = _interopRequireDefault(_Barcode2);
16
-
17
- var _UPC = require('./UPC.js');
18
-
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
-
23
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
24
-
25
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
1
+ // Encoding documentation:
26
2
  // https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
27
3
  //
28
4
  // UPC-E documentation:
29
5
  // https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E
30
6
 
31
- var EXPANSIONS = ["XX00000XXX", "XX10000XXX", "XX20000XXX", "XXX00000XX", "XXXX00000X", "XXXXX00005", "XXXXX00006", "XXXXX00007", "XXXXX00008", "XXXXX00009"];
32
-
33
- var PARITIES = [["EEEOOO", "OOOEEE"], ["EEOEOO", "OOEOEE"], ["EEOOEO", "OOEEOE"], ["EEOOOE", "OOEEEO"], ["EOEEOO", "OEOOEE"], ["EOOEEO", "OEEOOE"], ["EOOOEE", "OEEEOO"], ["EOEOEO", "OEOEOE"], ["EOEOOE", "OEOEEO"], ["EOOEOE", "OEEOEO"]];
34
-
35
- var UPCE = function (_Barcode) {
36
- _inherits(UPCE, _Barcode);
37
-
38
- function UPCE(data, options) {
39
- _classCallCheck(this, UPCE);
40
-
41
- var _this = _possibleConstructorReturn(this, (UPCE.__proto__ || Object.getPrototypeOf(UPCE)).call(this, data, options));
7
+ import encode from './encoder';
8
+ import Barcode from "../Barcode.js";
9
+ import { checksum } from './UPC.js';
10
+
11
+ const EXPANSIONS = [
12
+ "XX00000XXX",
13
+ "XX10000XXX",
14
+ "XX20000XXX",
15
+ "XXX00000XX",
16
+ "XXXX00000X",
17
+ "XXXXX00005",
18
+ "XXXXX00006",
19
+ "XXXXX00007",
20
+ "XXXXX00008",
21
+ "XXXXX00009"
22
+ ];
23
+
24
+ const PARITIES = [
25
+ ["EEEOOO", "OOOEEE"],
26
+ ["EEOEOO", "OOEOEE"],
27
+ ["EEOOEO", "OOEEOE"],
28
+ ["EEOOOE", "OOEEEO"],
29
+ ["EOEEOO", "OEOOEE"],
30
+ ["EOOEEO", "OEEOOE"],
31
+ ["EOOOEE", "OEEEOO"],
32
+ ["EOEOEO", "OEOEOE"],
33
+ ["EOEOOE", "OEOEEO"],
34
+ ["EOOEOE", "OEEOEO"]
35
+ ];
36
+
37
+ class UPCE extends Barcode{
38
+ constructor(data, options){
42
39
  // Code may be 6 or 8 digits;
43
40
  // A 7 digit code is ambiguous as to whether the extra digit
44
41
  // is a UPC-A check or number system digit.
42
+ super(data, options);
43
+ this.isValid = false;
44
+ if(data.search(/^[0-9]{6}$/) !== -1){
45
+ this.middleDigits = data;
46
+ this.upcA = expandToUPCA(data, "0");
47
+ this.text = options.text ||
48
+ `${this.upcA[0]}${data}${this.upcA[this.upcA.length - 1]}`;
49
+ this.isValid = true;
50
+ }
51
+ else if(data.search(/^[01][0-9]{7}$/) !== -1){
52
+ this.middleDigits = data.substring(1, data.length - 1);
53
+ this.upcA = expandToUPCA(this.middleDigits, data[0]);
45
54
 
46
-
47
- _this.isValid = false;
48
- if (data.search(/^[0-9]{6}$/) !== -1) {
49
- _this.middleDigits = data;
50
- _this.upcA = expandToUPCA(data, "0");
51
- _this.text = options.text || '' + _this.upcA[0] + data + _this.upcA[_this.upcA.length - 1];
52
- _this.isValid = true;
53
- } else if (data.search(/^[01][0-9]{7}$/) !== -1) {
54
- _this.middleDigits = data.substring(1, data.length - 1);
55
- _this.upcA = expandToUPCA(_this.middleDigits, data[0]);
56
-
57
- if (_this.upcA[_this.upcA.length - 1] === data[data.length - 1]) {
58
- _this.isValid = true;
59
- } else {
55
+ if(this.upcA[this.upcA.length - 1] === data[data.length - 1]){
56
+ this.isValid = true;
57
+ }
58
+ else{
60
59
  // checksum mismatch
61
- return _possibleConstructorReturn(_this);
60
+ return;
62
61
  }
63
- } else {
64
- return _possibleConstructorReturn(_this);
62
+ }
63
+ else{
64
+ return;
65
65
  }
66
66
 
67
- _this.displayValue = options.displayValue;
67
+ this.displayValue = options.displayValue;
68
68
 
69
69
  // Make sure the font is not bigger than the space between the guard bars
70
- if (options.fontSize > options.width * 10) {
71
- _this.fontSize = options.width * 10;
72
- } else {
73
- _this.fontSize = options.fontSize;
70
+ if(options.fontSize > options.width * 10){
71
+ this.fontSize = options.width * 10;
72
+ }
73
+ else{
74
+ this.fontSize = options.fontSize;
74
75
  }
75
76
 
76
77
  // Make the guard bars go down half the way of the text
77
- _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
78
- return _this;
78
+ this.guardHeight = options.height + this.fontSize / 2 + options.textMargin;
79
79
  }
80
80
 
81
- _createClass(UPCE, [{
82
- key: 'valid',
83
- value: function valid() {
84
- return this.isValid;
85
- }
86
- }, {
87
- key: 'encode',
88
- value: function encode() {
89
- if (this.options.flat) {
90
- return this.flatEncoding();
91
- } else {
92
- return this.guardedEncoding();
93
- }
81
+ valid(){
82
+ return this.isValid;
83
+ }
84
+
85
+ encode(){
86
+ if(this.options.flat){
87
+ return this.flatEncoding();
94
88
  }
95
- }, {
96
- key: 'flatEncoding',
97
- value: function flatEncoding() {
98
- var result = "";
99
-
100
- result += "101";
101
- result += this.encodeMiddleDigits();
102
- result += "010101";
103
-
104
- return {
105
- data: result,
106
- text: this.text
107
- };
89
+ else{
90
+ return this.guardedEncoding();
108
91
  }
109
- }, {
110
- key: 'guardedEncoding',
111
- value: function guardedEncoding() {
112
- var result = [];
113
-
114
- // Add the UPC-A number system digit beneath the quiet zone
115
- if (this.displayValue) {
116
- result.push({
117
- data: "00000000",
118
- text: this.text[0],
119
- options: { textAlign: "left", fontSize: this.fontSize }
120
- });
121
- }
92
+ }
122
93
 
123
- // Add the guard bars
124
- result.push({
125
- data: "101",
126
- options: { height: this.guardHeight }
127
- });
94
+ flatEncoding(){
95
+ var result = "";
96
+
97
+ result += "101";
98
+ result += this.encodeMiddleDigits();
99
+ result += "010101";
100
+
101
+ return {
102
+ data: result,
103
+ text: this.text
104
+ };
105
+ }
106
+
107
+ guardedEncoding(){
108
+ var result = [];
128
109
 
129
- // Add the 6 UPC-E digits
110
+ // Add the UPC-A number system digit beneath the quiet zone
111
+ if(this.displayValue){
130
112
  result.push({
131
- data: this.encodeMiddleDigits(),
132
- text: this.text.substring(1, 7),
133
- options: { fontSize: this.fontSize }
113
+ data: "00000000",
114
+ text: this.text[0],
115
+ options: {textAlign: "left", fontSize: this.fontSize}
134
116
  });
117
+ }
135
118
 
136
- // Add the end bits
119
+ // Add the guard bars
120
+ result.push({
121
+ data: "101",
122
+ options: {height: this.guardHeight}
123
+ });
124
+
125
+ // Add the 6 UPC-E digits
126
+ result.push({
127
+ data: this.encodeMiddleDigits(),
128
+ text: this.text.substring(1, 7),
129
+ options: {fontSize: this.fontSize}
130
+ });
131
+
132
+ // Add the end bits
133
+ result.push({
134
+ data: "010101",
135
+ options: {height: this.guardHeight}
136
+ });
137
+
138
+ // Add the UPC-A check digit beneath the quiet zone
139
+ if(this.displayValue){
137
140
  result.push({
138
- data: "010101",
139
- options: { height: this.guardHeight }
141
+ data: "00000000",
142
+ text: this.text[7],
143
+ options: {textAlign: "right", fontSize: this.fontSize}
140
144
  });
141
-
142
- // Add the UPC-A check digit beneath the quiet zone
143
- if (this.displayValue) {
144
- result.push({
145
- data: "00000000",
146
- text: this.text[7],
147
- options: { textAlign: "right", fontSize: this.fontSize }
148
- });
149
- }
150
-
151
- return result;
152
145
  }
153
- }, {
154
- key: 'encodeMiddleDigits',
155
- value: function encodeMiddleDigits() {
156
- var numberSystem = this.upcA[0];
157
- var checkDigit = this.upcA[this.upcA.length - 1];
158
- var parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
159
- return (0, _encoder2.default)(this.middleDigits, parity);
160
- }
161
- }]);
162
146
 
163
- return UPCE;
164
- }(_Barcode3.default);
147
+ return result;
148
+ }
149
+
150
+ encodeMiddleDigits() {
151
+ const numberSystem = this.upcA[0];
152
+ const checkDigit = this.upcA[this.upcA.length - 1];
153
+ const parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
154
+ return encode(this.middleDigits, parity);
155
+ }
156
+ }
165
157
 
166
158
  function expandToUPCA(middleDigits, numberSystem) {
167
- var lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
168
- var expansion = EXPANSIONS[lastUpcE];
159
+ const lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
160
+ const expansion = EXPANSIONS[lastUpcE];
169
161
 
170
- var result = "";
171
- var digitIndex = 0;
172
- for (var i = 0; i < expansion.length; i++) {
173
- var c = expansion[i];
162
+ let result = "";
163
+ let digitIndex = 0;
164
+ for(let i = 0; i < expansion.length; i++) {
165
+ let c = expansion[i];
174
166
  if (c === 'X') {
175
167
  result += middleDigits[digitIndex++];
176
168
  } else {
@@ -178,8 +170,8 @@ function expandToUPCA(middleDigits, numberSystem) {
178
170
  }
179
171
  }
180
172
 
181
- result = '' + numberSystem + result;
182
- return '' + result + (0, _UPC.checksum)(result);
173
+ result = `${numberSystem}${result}`;
174
+ return `${result}${checksum(result)}`;
183
175
  }
184
176
 
185
- exports.default = UPCE;
177
+ export default UPCE;
@@ -1,30 +1,41 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
1
  // Standard start end and middle bits
7
- var SIDE_BIN = exports.SIDE_BIN = '101';
8
- var MIDDLE_BIN = exports.MIDDLE_BIN = '01010';
2
+ export const SIDE_BIN = '101';
3
+ export const MIDDLE_BIN = '01010';
9
4
 
10
- var BINARIES = exports.BINARIES = {
11
- 'L': [// The L (left) type of encoding
12
- '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
13
- 'G': [// The G type of encoding
14
- '0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111'],
15
- 'R': [// The R (right) type of encoding
16
- '1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000', '1110100'],
17
- 'O': [// The O (odd) encoding for UPC-E
18
- '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
19
- 'E': [// The E (even) encoding for UPC-E
20
- '0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111']
5
+ export const BINARIES = {
6
+ 'L': [ // The L (left) type of encoding
7
+ '0001101', '0011001', '0010011', '0111101', '0100011',
8
+ '0110001', '0101111', '0111011', '0110111', '0001011'
9
+ ],
10
+ 'G': [ // The G type of encoding
11
+ '0100111', '0110011', '0011011', '0100001', '0011101',
12
+ '0111001', '0000101', '0010001', '0001001', '0010111'
13
+ ],
14
+ 'R': [ // The R (right) type of encoding
15
+ '1110010', '1100110', '1101100', '1000010', '1011100',
16
+ '1001110', '1010000', '1000100', '1001000', '1110100'
17
+ ],
18
+ 'O': [ // The O (odd) encoding for UPC-E
19
+ '0001101', '0011001', '0010011', '0111101', '0100011',
20
+ '0110001', '0101111', '0111011', '0110111', '0001011'
21
+ ],
22
+ 'E': [ // The E (even) encoding for UPC-E
23
+ '0100111', '0110011', '0011011', '0100001', '0011101',
24
+ '0111001', '0000101', '0010001', '0001001', '0010111'
25
+ ]
21
26
  };
22
27
 
23
28
  // Define the EAN-2 structure
24
- var EAN2_STRUCTURE = exports.EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
29
+ export const EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
25
30
 
26
31
  // Define the EAN-5 structure
27
- var EAN5_STRUCTURE = exports.EAN5_STRUCTURE = ['GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL', 'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'];
32
+ export const EAN5_STRUCTURE = [
33
+ 'GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL',
34
+ 'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'
35
+ ];
28
36
 
29
37
  // Define the EAN-13 structure
30
- var EAN13_STRUCTURE = exports.EAN13_STRUCTURE = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL'];
38
+ export const EAN13_STRUCTURE = [
39
+ 'LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG',
40
+ 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL'
41
+ ];
@@ -1,27 +1,20 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _constants = require('./constants');
1
+ import { BINARIES } from './constants';
8
2
 
9
3
  // Encode data string
10
- var encode = function encode(data, structure, separator) {
11
- var encoded = data.split('').map(function (val, idx) {
12
- return _constants.BINARIES[structure[idx]];
13
- }).map(function (val, idx) {
14
- return val ? val[data[idx]] : '';
15
- });
4
+ const encode = (data, structure, separator) => {
5
+ let encoded = data
6
+ .split('')
7
+ .map((val, idx) => BINARIES[structure[idx]])
8
+ .map((val, idx) => val ? val[data[idx]] : '');
16
9
 
17
10
  if (separator) {
18
- var last = data.length - 1;
19
- encoded = encoded.map(function (val, idx) {
20
- return idx < last ? val + separator : val;
21
- });
11
+ const last = data.length - 1;
12
+ encoded = encoded.map((val, idx) => (
13
+ idx < last ? val + separator : val
14
+ ));
22
15
  }
23
16
 
24
17
  return encoded.join('');
25
18
  };
26
19
 
27
- exports.default = encode;
20
+ export default encode;
@@ -1,39 +1,8 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.UPCE = exports.UPC = exports.EAN2 = exports.EAN5 = exports.EAN8 = exports.EAN13 = undefined;
7
-
8
- var _EAN = require('./EAN13.js');
9
-
10
- var _EAN2 = _interopRequireDefault(_EAN);
11
-
12
- var _EAN3 = require('./EAN8.js');
13
-
14
- var _EAN4 = _interopRequireDefault(_EAN3);
15
-
16
- var _EAN5 = require('./EAN5.js');
17
-
18
- var _EAN6 = _interopRequireDefault(_EAN5);
19
-
20
- var _EAN7 = require('./EAN2.js');
21
-
22
- var _EAN8 = _interopRequireDefault(_EAN7);
23
-
24
- var _UPC = require('./UPC.js');
25
-
26
- var _UPC2 = _interopRequireDefault(_UPC);
27
-
28
- var _UPCE = require('./UPCE.js');
29
-
30
- var _UPCE2 = _interopRequireDefault(_UPCE);
31
-
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
-
34
- exports.EAN13 = _EAN2.default;
35
- exports.EAN8 = _EAN4.default;
36
- exports.EAN5 = _EAN6.default;
37
- exports.EAN2 = _EAN8.default;
38
- exports.UPC = _UPC2.default;
39
- exports.UPCE = _UPCE2.default;
1
+ import EAN13 from './EAN13.js';
2
+ import EAN8 from './EAN8.js';
3
+ import EAN5 from './EAN5.js';
4
+ import EAN2 from './EAN2.js';
5
+ import UPC from './UPC.js';
6
+ import UPCE from './UPCE.js';
7
+
8
+ export {EAN13, EAN8, EAN5, EAN2, UPC, UPCE};
@@ -1,55 +1,22 @@
1
- "use strict";
1
+ import Barcode from "../Barcode.js";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GenericBarcode = undefined;
7
-
8
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9
-
10
- var _Barcode2 = require("../Barcode.js");
11
-
12
- var _Barcode3 = _interopRequireDefault(_Barcode2);
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
-
18
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
19
-
20
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
21
-
22
- var GenericBarcode = function (_Barcode) {
23
- _inherits(GenericBarcode, _Barcode);
24
-
25
- function GenericBarcode(data, options) {
26
- _classCallCheck(this, GenericBarcode);
27
-
28
- return _possibleConstructorReturn(this, (GenericBarcode.__proto__ || Object.getPrototypeOf(GenericBarcode)).call(this, data, options)); // Sets this.data and this.text
3
+ class GenericBarcode extends Barcode{
4
+ constructor(data, options){
5
+ super(data, options); // Sets this.data and this.text
29
6
  }
30
7
 
31
8
  // Return the corresponding binary numbers for the data provided
9
+ encode(){
10
+ return {
11
+ data: "10101010101010101010101010101010101010101",
12
+ text: this.text
13
+ };
14
+ }
32
15
 
16
+ // Resturn true/false if the string provided is valid for this encoder
17
+ valid(){
18
+ return true;
19
+ }
20
+ }
33
21
 
34
- _createClass(GenericBarcode, [{
35
- key: "encode",
36
- value: function encode() {
37
- return {
38
- data: "10101010101010101010101010101010101010101",
39
- text: this.text
40
- };
41
- }
42
-
43
- // Resturn true/false if the string provided is valid for this encoder
44
-
45
- }, {
46
- key: "valid",
47
- value: function valid() {
48
- return true;
49
- }
50
- }]);
51
-
52
- return GenericBarcode;
53
- }(_Barcode3.default);
54
-
55
- exports.GenericBarcode = GenericBarcode;
22
+ export {GenericBarcode};
@@ -1,69 +1,37 @@
1
- 'use strict';
1
+ import { START_BIN, END_BIN, BINARIES } from './constants';
2
+ import Barcode from '../Barcode';
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
4
+ class ITF extends Barcode {
6
5
 
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- var _constants = require('./constants');
10
-
11
- var _Barcode2 = require('../Barcode');
12
-
13
- var _Barcode3 = _interopRequireDefault(_Barcode2);
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
-
19
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
20
-
21
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
22
-
23
- var ITF = function (_Barcode) {
24
- _inherits(ITF, _Barcode);
25
-
26
- function ITF() {
27
- _classCallCheck(this, ITF);
28
-
29
- return _possibleConstructorReturn(this, (ITF.__proto__ || Object.getPrototypeOf(ITF)).apply(this, arguments));
6
+ valid() {
7
+ return this.data.search(/^([0-9]{2})+$/) !== -1;
30
8
  }
31
9
 
32
- _createClass(ITF, [{
33
- key: 'valid',
34
- value: function valid() {
35
- return this.data.search(/^([0-9]{2})+$/) !== -1;
36
- }
37
- }, {
38
- key: 'encode',
39
- value: function encode() {
40
- var _this2 = this;
41
-
42
- // Calculate all the digit pairs
43
- var encoded = this.data.match(/.{2}/g).map(function (pair) {
44
- return _this2.encodePair(pair);
45
- }).join('');
46
-
47
- return {
48
- data: _constants.START_BIN + encoded + _constants.END_BIN,
49
- text: this.text
50
- };
51
- }
52
-
53
- // Calculate the data of a number pair
54
-
55
- }, {
56
- key: 'encodePair',
57
- value: function encodePair(pair) {
58
- var second = _constants.BINARIES[pair[1]];
59
-
60
- return _constants.BINARIES[pair[0]].split('').map(function (first, idx) {
61
- return (first === '1' ? '111' : '1') + (second[idx] === '1' ? '000' : '0');
62
- }).join('');
63
- }
64
- }]);
10
+ encode() {
11
+ // Calculate all the digit pairs
12
+ const encoded = this.data
13
+ .match(/.{2}/g)
14
+ .map(pair => this.encodePair(pair))
15
+ .join('');
16
+
17
+ return {
18
+ data: START_BIN + encoded + END_BIN,
19
+ text: this.text
20
+ };
21
+ }
65
22
 
66
- return ITF;
67
- }(_Barcode3.default);
23
+ // Calculate the data of a number pair
24
+ encodePair(pair) {
25
+ const second = BINARIES[pair[1]];
26
+
27
+ return BINARIES[pair[0]]
28
+ .split('')
29
+ .map((first, idx) => (
30
+ (first === '1' ? '111' : '1') +
31
+ (second[idx] === '1' ? '000' : '0')
32
+ ))
33
+ .join('');
34
+ }
35
+ }
68
36
 
69
- exports.default = ITF;
37
+ export default ITF;