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,17 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
-
9
- var Barcode = function Barcode(data, options) {
10
- _classCallCheck(this, Barcode);
11
-
12
- this.data = data;
13
- this.text = options.text || data;
14
- this.options = options;
15
- };
16
-
17
- exports.default = Barcode;
1
+ class Barcode{
2
+ constructor(data, options){
3
+ this.data = data;
4
+ this.text = options.text || data;
5
+ this.options = options;
6
+ }
7
+ }
8
+
9
+ export default Barcode;
@@ -1,167 +1,127 @@
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 _Barcode2 = require('../Barcode.js');
10
-
11
- var _Barcode3 = _interopRequireDefault(_Barcode2);
12
-
13
- var _constants = require('./constants');
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; }
1
+ import Barcode from "../Barcode.js";
2
+ import { SHIFT, SET_A, SET_B, MODULO, STOP, FNC1, SET_BY_CODE, SWAP, BARS } from './constants';
22
3
 
23
4
  // This is the master class,
24
5
  // it does require the start code to be included in the string
25
- var CODE128 = function (_Barcode) {
26
- _inherits(CODE128, _Barcode);
27
-
28
- function CODE128(data, options) {
29
- _classCallCheck(this, CODE128);
6
+ class CODE128 extends Barcode {
7
+ constructor(data, options) {
8
+ super(data.substring(1), options);
30
9
 
31
10
  // Get array of ascii codes from data
32
- var _this = _possibleConstructorReturn(this, (CODE128.__proto__ || Object.getPrototypeOf(CODE128)).call(this, data.substring(1), options));
33
-
34
- _this.bytes = data.split('').map(function (char) {
35
- return char.charCodeAt(0);
36
- });
37
- return _this;
11
+ this.bytes = data.split('')
12
+ .map(char => char.charCodeAt(0));
38
13
  }
39
14
 
40
- _createClass(CODE128, [{
41
- key: 'valid',
42
- value: function valid() {
43
- // ASCII value ranges 0-127, 200-211
44
- return (/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)
45
- );
46
- }
47
-
48
- // The public encoding function
15
+ valid() {
16
+ // ASCII value ranges 0-127, 200-211
17
+ return /^[\x00-\x7F\xC8-\xD3]+$/.test(this.data);
18
+ }
49
19
 
50
- }, {
51
- key: 'encode',
52
- value: function encode() {
53
- var bytes = this.bytes;
54
- // Remove the start code from the bytes and set its index
55
- var startIndex = bytes.shift() - 105;
56
- // Get start set by index
57
- var startSet = _constants.SET_BY_CODE[startIndex];
20
+ // The public encoding function
21
+ encode() {
22
+ const bytes = this.bytes;
23
+ // Remove the start code from the bytes and set its index
24
+ const startIndex = bytes.shift() - 105;
25
+ // Get start set by index
26
+ const startSet = SET_BY_CODE[startIndex];
58
27
 
59
- if (startSet === undefined) {
60
- throw new RangeError('The encoding does not start with a start character.');
61
- }
28
+ if (startSet === undefined) {
29
+ throw new RangeError('The encoding does not start with a start character.');
30
+ }
62
31
 
63
- if (this.shouldEncodeAsEan128() === true) {
64
- bytes.unshift(_constants.FNC1);
65
- }
32
+ if (this.shouldEncodeAsEan128() === true) {
33
+ bytes.unshift(FNC1);
34
+ }
66
35
 
67
- // Start encode with the right type
68
- var encodingResult = CODE128.next(bytes, 1, startSet);
36
+ // Start encode with the right type
37
+ const encodingResult = CODE128.next(bytes, 1, startSet);
69
38
 
70
- return {
71
- text: this.text === this.data ? this.text.replace(/[^\x20-\x7E]/g, '') : this.text,
72
- data:
39
+ return {
40
+ text:
41
+ this.text === this.data
42
+ ? this.text.replace(/[^\x20-\x7E]/g, '')
43
+ : this.text,
44
+ data:
73
45
  // Add the start bits
74
46
  CODE128.getBar(startIndex) +
75
47
  // Add the encoded bits
76
48
  encodingResult.result +
77
49
  // Add the checksum
78
- CODE128.getBar((encodingResult.checksum + startIndex) % _constants.MODULO) +
50
+ CODE128.getBar((encodingResult.checksum + startIndex) % MODULO) +
79
51
  // Add the end bits
80
- CODE128.getBar(_constants.STOP)
81
- };
82
- }
83
-
84
- // GS1-128/EAN-128
52
+ CODE128.getBar(STOP)
53
+ };
54
+ }
85
55
 
86
- }, {
87
- key: 'shouldEncodeAsEan128',
88
- value: function shouldEncodeAsEan128() {
89
- var isEAN128 = this.options.ean128 || false;
90
- if (typeof isEAN128 === 'string') {
91
- isEAN128 = isEAN128.toLowerCase() === 'true';
92
- }
93
- return isEAN128;
56
+ // GS1-128/EAN-128
57
+ shouldEncodeAsEan128() {
58
+ let isEAN128 = this.options.ean128 || false;
59
+ if (typeof isEAN128 === 'string') {
60
+ isEAN128 = isEAN128.toLowerCase() === 'true';
94
61
  }
62
+ return isEAN128;
63
+ }
95
64
 
96
- // Get a bar symbol by index
65
+ // Get a bar symbol by index
66
+ static getBar(index) {
67
+ return BARS[index] ? BARS[index].toString() : '';
68
+ }
97
69
 
98
- }], [{
99
- key: 'getBar',
100
- value: function getBar(index) {
101
- return _constants.BARS[index] ? _constants.BARS[index].toString() : '';
70
+ // Correct an index by a set and shift it from the bytes array
71
+ static correctIndex(bytes, set) {
72
+ if (set === SET_A) {
73
+ const charCode = bytes.shift();
74
+ return charCode < 32 ? charCode + 64 : charCode - 32;
75
+ } else if (set === SET_B) {
76
+ return bytes.shift() - 32;
77
+ } else {
78
+ return (bytes.shift() - 48) * 10 + bytes.shift() - 48;
102
79
  }
80
+ }
103
81
 
104
- // Correct an index by a set and shift it from the bytes array
105
-
106
- }, {
107
- key: 'correctIndex',
108
- value: function correctIndex(bytes, set) {
109
- if (set === _constants.SET_A) {
110
- var charCode = bytes.shift();
111
- return charCode < 32 ? charCode + 64 : charCode - 32;
112
- } else if (set === _constants.SET_B) {
113
- return bytes.shift() - 32;
114
- } else {
115
- return (bytes.shift() - 48) * 10 + bytes.shift() - 48;
116
- }
82
+ static next(bytes, pos, set) {
83
+ if (!bytes.length) {
84
+ return { result: '', checksum: 0 };
117
85
  }
118
- }, {
119
- key: 'next',
120
- value: function next(bytes, pos, set) {
121
- if (!bytes.length) {
122
- return { result: '', checksum: 0 };
123
- }
124
86
 
125
- var nextCode = void 0,
126
- index = void 0;
87
+ let nextCode, index;
127
88
 
128
- // Special characters
129
- if (bytes[0] >= 200) {
130
- index = bytes.shift() - 105;
131
- var nextSet = _constants.SWAP[index];
89
+ // Special characters
90
+ if (bytes[0] >= 200){
91
+ index = bytes.shift() - 105;
92
+ const nextSet = SWAP[index];
132
93
 
133
- // Swap to other set
134
- if (nextSet !== undefined) {
135
- nextCode = CODE128.next(bytes, pos + 1, nextSet);
136
- }
137
- // Continue on current set but encode a special character
138
- else {
139
- // Shift
140
- if ((set === _constants.SET_A || set === _constants.SET_B) && index === _constants.SHIFT) {
141
- // Convert the next character so that is encoded correctly
142
- bytes[0] = set === _constants.SET_A ? bytes[0] > 95 ? bytes[0] - 96 : bytes[0] : bytes[0] < 32 ? bytes[0] + 96 : bytes[0];
143
- }
144
- nextCode = CODE128.next(bytes, pos + 1, set);
145
- }
94
+ // Swap to other set
95
+ if (nextSet !== undefined) {
96
+ nextCode = CODE128.next(bytes, pos + 1, nextSet);
146
97
  }
147
- // Continue encoding
98
+ // Continue on current set but encode a special character
148
99
  else {
149
- index = CODE128.correctIndex(bytes, set);
150
- nextCode = CODE128.next(bytes, pos + 1, set);
100
+ // Shift
101
+ if ((set === SET_A || set === SET_B) && index === SHIFT) {
102
+ // Convert the next character so that is encoded correctly
103
+ bytes[0] = (set === SET_A)
104
+ ? bytes[0] > 95 ? bytes[0] - 96 : bytes[0]
105
+ : bytes[0] < 32 ? bytes[0] + 96 : bytes[0];
151
106
  }
152
-
153
- // Get the correct binary encoding and calculate the weight
154
- var enc = CODE128.getBar(index);
155
- var weight = index * pos;
156
-
157
- return {
158
- result: enc + nextCode.result,
159
- checksum: weight + nextCode.checksum
160
- };
107
+ nextCode = CODE128.next(bytes, pos + 1, set);
108
+ }
109
+ }
110
+ // Continue encoding
111
+ else {
112
+ index = CODE128.correctIndex(bytes, set);
113
+ nextCode = CODE128.next(bytes, pos + 1, set);
161
114
  }
162
- }]);
163
115
 
164
- return CODE128;
165
- }(_Barcode3.default);
116
+ // Get the correct binary encoding and calculate the weight
117
+ const enc = CODE128.getBar(index);
118
+ const weight = index * pos;
119
+
120
+ return {
121
+ result: enc + nextCode.result,
122
+ checksum: weight + nextCode.checksum
123
+ };
124
+ }
125
+ }
166
126
 
167
- exports.default = CODE128;
127
+ export default CODE128;
@@ -1,42 +1,14 @@
1
- 'use strict';
1
+ import CODE128 from './CODE128.js';
2
+ import { A_START_CHAR, A_CHARS } from './constants';
2
3
 
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 _CODE2 = require('./CODE128.js');
10
-
11
- var _CODE3 = _interopRequireDefault(_CODE2);
12
-
13
- var _constants = require('./constants');
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 CODE128A = function (_CODE) {
24
- _inherits(CODE128A, _CODE);
25
-
26
- function CODE128A(string, options) {
27
- _classCallCheck(this, CODE128A);
28
-
29
- return _possibleConstructorReturn(this, (CODE128A.__proto__ || Object.getPrototypeOf(CODE128A)).call(this, _constants.A_START_CHAR + string, options));
4
+ class CODE128A extends CODE128 {
5
+ constructor(string, options) {
6
+ super(A_START_CHAR + string, options);
30
7
  }
31
8
 
32
- _createClass(CODE128A, [{
33
- key: 'valid',
34
- value: function valid() {
35
- return new RegExp('^' + _constants.A_CHARS + '+$').test(this.data);
36
- }
37
- }]);
38
-
39
- return CODE128A;
40
- }(_CODE3.default);
9
+ valid() {
10
+ return (new RegExp(`^${A_CHARS}+$`)).test(this.data);
11
+ }
12
+ }
41
13
 
42
- exports.default = CODE128A;
14
+ export default CODE128A;
@@ -1,42 +1,14 @@
1
- 'use strict';
1
+ import CODE128 from './CODE128.js';
2
+ import { B_START_CHAR, B_CHARS } from './constants';
2
3
 
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 _CODE2 = require('./CODE128.js');
10
-
11
- var _CODE3 = _interopRequireDefault(_CODE2);
12
-
13
- var _constants = require('./constants');
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 CODE128B = function (_CODE) {
24
- _inherits(CODE128B, _CODE);
25
-
26
- function CODE128B(string, options) {
27
- _classCallCheck(this, CODE128B);
28
-
29
- return _possibleConstructorReturn(this, (CODE128B.__proto__ || Object.getPrototypeOf(CODE128B)).call(this, _constants.B_START_CHAR + string, options));
4
+ class CODE128B extends CODE128 {
5
+ constructor(string, options) {
6
+ super(B_START_CHAR + string, options);
30
7
  }
31
8
 
32
- _createClass(CODE128B, [{
33
- key: 'valid',
34
- value: function valid() {
35
- return new RegExp('^' + _constants.B_CHARS + '+$').test(this.data);
36
- }
37
- }]);
38
-
39
- return CODE128B;
40
- }(_CODE3.default);
9
+ valid() {
10
+ return (new RegExp(`^${B_CHARS}+$`)).test(this.data);
11
+ }
12
+ }
41
13
 
42
- exports.default = CODE128B;
14
+ export default CODE128B;
@@ -1,42 +1,14 @@
1
- 'use strict';
1
+ import CODE128 from './CODE128.js';
2
+ import { C_START_CHAR, C_CHARS } from './constants';
2
3
 
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 _CODE2 = require('./CODE128.js');
10
-
11
- var _CODE3 = _interopRequireDefault(_CODE2);
12
-
13
- var _constants = require('./constants');
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 CODE128C = function (_CODE) {
24
- _inherits(CODE128C, _CODE);
25
-
26
- function CODE128C(string, options) {
27
- _classCallCheck(this, CODE128C);
28
-
29
- return _possibleConstructorReturn(this, (CODE128C.__proto__ || Object.getPrototypeOf(CODE128C)).call(this, _constants.C_START_CHAR + string, options));
4
+ class CODE128C extends CODE128 {
5
+ constructor(string, options) {
6
+ super(C_START_CHAR + string, options);
30
7
  }
31
8
 
32
- _createClass(CODE128C, [{
33
- key: 'valid',
34
- value: function valid() {
35
- return new RegExp('^' + _constants.C_CHARS + '+$').test(this.data);
36
- }
37
- }]);
38
-
39
- return CODE128C;
40
- }(_CODE3.default);
9
+ valid() {
10
+ return (new RegExp(`^${C_CHARS}+$`)).test(this.data);
11
+ }
12
+ }
41
13
 
42
- exports.default = CODE128C;
14
+ export default CODE128C;
@@ -1,41 +1,15 @@
1
- 'use strict';
1
+ import CODE128 from './CODE128';
2
+ import autoSelectModes from './auto';
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _CODE2 = require('./CODE128');
8
-
9
- var _CODE3 = _interopRequireDefault(_CODE2);
10
-
11
- var _auto = require('./auto');
12
-
13
- var _auto2 = _interopRequireDefault(_auto);
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 CODE128AUTO = function (_CODE) {
24
- _inherits(CODE128AUTO, _CODE);
25
-
26
- function CODE128AUTO(data, options) {
27
- _classCallCheck(this, CODE128AUTO);
28
-
29
- // ASCII value ranges 0-127, 200-211
4
+ class CODE128AUTO extends CODE128{
5
+ constructor(data, options){
6
+ // ASCII value ranges 0-127, 200-211
30
7
  if (/^[\x00-\x7F\xC8-\xD3]+$/.test(data)) {
31
- var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, (0, _auto2.default)(data), options));
32
- } else {
33
- var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, data, options));
8
+ super(autoSelectModes(data), options);
9
+ } else{
10
+ super(data, options);
34
11
  }
35
- return _possibleConstructorReturn(_this);
36
12
  }
13
+ }
37
14
 
38
- return CODE128AUTO;
39
- }(_CODE3.default);
40
-
41
- exports.default = CODE128AUTO;
15
+ export default CODE128AUTO;
@@ -1,44 +1,40 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _constants = require('./constants');
1
+ import { A_START_CHAR, B_START_CHAR, C_START_CHAR, A_CHARS, B_CHARS, C_CHARS } from './constants';
8
2
 
9
3
  // Match Set functions
10
- var matchSetALength = function matchSetALength(string) {
11
- return string.match(new RegExp('^' + _constants.A_CHARS + '*'))[0].length;
12
- };
13
- var matchSetBLength = function matchSetBLength(string) {
14
- return string.match(new RegExp('^' + _constants.B_CHARS + '*'))[0].length;
15
- };
16
- var matchSetC = function matchSetC(string) {
17
- return string.match(new RegExp('^' + _constants.C_CHARS + '*'))[0];
18
- };
4
+ const matchSetALength = (string) => string.match(new RegExp(`^${A_CHARS}*`))[0].length;
5
+ const matchSetBLength = (string) => string.match(new RegExp(`^${B_CHARS}*`))[0].length;
6
+ const matchSetC = (string) => string.match(new RegExp(`^${C_CHARS}*`))[0];
19
7
 
20
8
  // CODE128A or CODE128B
21
- function autoSelectFromAB(string, isA) {
22
- var ranges = isA ? _constants.A_CHARS : _constants.B_CHARS;
23
- var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)'));
9
+ function autoSelectFromAB(string, isA){
10
+ const ranges = isA ? A_CHARS : B_CHARS;
11
+ const untilC = string.match(new RegExp(`^(${ranges}+?)(([0-9]{2}){2,})([^0-9]|$)`));
24
12
 
25
13
  if (untilC) {
26
- return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));
14
+ return (
15
+ untilC[1] +
16
+ String.fromCharCode(204) +
17
+ autoSelectFromC(string.substring(untilC[1].length))
18
+ );
27
19
  }
28
20
 
29
- var chars = string.match(new RegExp('^' + ranges + '+'))[0];
21
+ const chars = string.match(new RegExp(`^${ranges}+`))[0];
30
22
 
31
23
  if (chars.length === string.length) {
32
24
  return string;
33
25
  }
34
26
 
35
- return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA);
27
+ return (
28
+ chars +
29
+ String.fromCharCode(isA ? 205 : 206) +
30
+ autoSelectFromAB(string.substring(chars.length), !isA)
31
+ );
36
32
  }
37
33
 
38
34
  // CODE128C
39
35
  function autoSelectFromC(string) {
40
- var cMatch = matchSetC(string);
41
- var length = cMatch.length;
36
+ const cMatch = matchSetC(string);
37
+ const length = cMatch.length;
42
38
 
43
39
  if (length === string.length) {
44
40
  return string;
@@ -47,27 +43,26 @@ function autoSelectFromC(string) {
47
43
  string = string.substring(length);
48
44
 
49
45
  // Select A/B depending on the longest match
50
- var isA = matchSetALength(string) >= matchSetBLength(string);
46
+ const isA = matchSetALength(string) >= matchSetBLength(string);
51
47
  return cMatch + String.fromCharCode(isA ? 206 : 205) + autoSelectFromAB(string, isA);
52
48
  }
53
49
 
54
50
  // Detect Code Set (A, B or C) and format the string
55
-
56
- exports.default = function (string) {
57
- var newString = void 0;
58
- var cLength = matchSetC(string).length;
51
+ export default (string) => {
52
+ let newString;
53
+ const cLength = matchSetC(string).length;
59
54
 
60
55
  // Select 128C if the string start with enough digits
61
56
  if (cLength >= 2) {
62
- newString = _constants.C_START_CHAR + autoSelectFromC(string);
57
+ newString = C_START_CHAR + autoSelectFromC(string);
63
58
  } else {
64
59
  // Select A/B depending on the longest match
65
- var isA = matchSetALength(string) > matchSetBLength(string);
66
- newString = (isA ? _constants.A_START_CHAR : _constants.B_START_CHAR) + autoSelectFromAB(string, isA);
60
+ const isA = matchSetALength(string) > matchSetBLength(string);
61
+ newString = (isA ? A_START_CHAR : B_START_CHAR) + autoSelectFromAB(string, isA);
67
62
  }
68
63
 
69
- return newString.replace(/[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters
70
- function (match, char) {
71
- return String.fromCharCode(203) + char;
72
- });
73
- };
64
+ return newString.replace(
65
+ /[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters
66
+ (match, char) => String.fromCharCode(203) + char
67
+ );
68
+ };