@aidc-toolkit/gs1 1.0.31-beta → 1.0.33-beta

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 (110) hide show
  1. package/README.md +290 -17
  2. package/dist/character-set.d.ts +17 -2
  3. package/dist/character-set.d.ts.map +1 -1
  4. package/dist/character-set.js +44 -11
  5. package/dist/character-set.js.map +1 -1
  6. package/dist/gcp-length-cache.d.ts +81 -0
  7. package/dist/gcp-length-cache.d.ts.map +1 -0
  8. package/dist/gcp-length-cache.js +232 -0
  9. package/dist/gcp-length-cache.js.map +1 -0
  10. package/dist/gcp-length-data.d.ts +108 -0
  11. package/dist/gcp-length-data.d.ts.map +1 -0
  12. package/dist/gcp-length-data.js +53 -0
  13. package/dist/gcp-length-data.js.map +1 -0
  14. package/dist/gcp-length.d.ts +61 -0
  15. package/dist/gcp-length.d.ts.map +1 -0
  16. package/dist/gcp-length.js +300 -0
  17. package/dist/gcp-length.js.map +1 -0
  18. package/dist/gtin-creator.d.ts +0 -17
  19. package/dist/gtin-creator.d.ts.map +1 -1
  20. package/dist/gtin-creator.js +1 -93
  21. package/dist/gtin-creator.js.map +1 -1
  22. package/dist/gtin-validator.d.ts +1 -46
  23. package/dist/gtin-validator.d.ts.map +1 -1
  24. package/dist/gtin-validator.js +31 -125
  25. package/dist/gtin-validator.js.map +1 -1
  26. package/dist/identifier-validator.d.ts +1 -4
  27. package/dist/identifier-validator.d.ts.map +1 -1
  28. package/dist/identifier-validator.js +2 -5
  29. package/dist/identifier-validator.js.map +1 -1
  30. package/dist/index.d.ts +5 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +4 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/locale/en/locale-resources.d.ts +39 -35
  35. package/dist/locale/en/locale-resources.d.ts.map +1 -1
  36. package/dist/locale/en/locale-resources.js +6 -2
  37. package/dist/locale/en/locale-resources.js.map +1 -1
  38. package/dist/locale/fr/locale-resources.d.ts +39 -35
  39. package/dist/locale/fr/locale-resources.d.ts.map +1 -1
  40. package/dist/locale/fr/locale-resources.js +6 -2
  41. package/dist/locale/fr/locale-resources.js.map +1 -1
  42. package/dist/locale/i18n.d.ts +4 -4
  43. package/dist/locale/i18n.d.ts.map +1 -1
  44. package/dist/locale/i18n.js +6 -7
  45. package/dist/locale/i18n.js.map +1 -1
  46. package/dist/non-numeric-identifier-validator.js +1 -1
  47. package/dist/non-numeric-identifier-validator.js.map +1 -1
  48. package/dist/numeric-identifier-validator.d.ts.map +1 -1
  49. package/dist/numeric-identifier-validator.js +2 -2
  50. package/dist/numeric-identifier-validator.js.map +1 -1
  51. package/dist/prefix-manager.d.ts +35 -0
  52. package/dist/prefix-manager.d.ts.map +1 -1
  53. package/dist/prefix-manager.js +56 -0
  54. package/dist/prefix-manager.js.map +1 -1
  55. package/dist/prefix-validator.d.ts +5 -4
  56. package/dist/prefix-validator.d.ts.map +1 -1
  57. package/dist/prefix-validator.js +18 -22
  58. package/dist/prefix-validator.js.map +1 -1
  59. package/dist/serializable-numeric-identifier-validator.d.ts +26 -0
  60. package/dist/serializable-numeric-identifier-validator.d.ts.map +1 -1
  61. package/dist/serializable-numeric-identifier-validator.js +19 -0
  62. package/dist/serializable-numeric-identifier-validator.js.map +1 -1
  63. package/dist/variable-measure.d.ts +68 -0
  64. package/dist/variable-measure.d.ts.map +1 -0
  65. package/dist/variable-measure.js +210 -0
  66. package/dist/variable-measure.js.map +1 -0
  67. package/dist/verified-by-gs1.d.ts +22 -0
  68. package/dist/verified-by-gs1.d.ts.map +1 -0
  69. package/dist/verified-by-gs1.js +46 -0
  70. package/dist/verified-by-gs1.js.map +1 -0
  71. package/package.json +12 -11
  72. package/src/character-set.ts +55 -11
  73. package/src/gcp-length-cache.ts +271 -0
  74. package/src/gcp-length-data.ts +136 -0
  75. package/src/gcp-length.ts +380 -0
  76. package/src/gtin-creator.ts +1 -117
  77. package/src/gtin-validator.ts +42 -173
  78. package/src/identifier-validator.ts +2 -5
  79. package/src/index.ts +7 -1
  80. package/src/locale/en/locale-resources.ts +7 -3
  81. package/src/locale/fr/locale-resources.ts +7 -3
  82. package/src/locale/i18n.ts +7 -8
  83. package/src/locale/i18next.d.ts +2 -0
  84. package/src/non-numeric-identifier-validator.ts +1 -1
  85. package/src/numeric-identifier-validator.ts +3 -3
  86. package/src/prefix-manager.ts +65 -0
  87. package/src/prefix-validator.ts +19 -23
  88. package/src/serializable-numeric-identifier-validator.ts +36 -0
  89. package/src/variable-measure.ts +268 -0
  90. package/src/verified-by-gs1.ts +54 -0
  91. package/test/character-set.test.ts +46 -0
  92. package/test/creator.test.ts +5 -5
  93. package/test/data/gcpprefixformatlist-1.json +662625 -0
  94. package/test/data/gcpprefixformatlist-2.json +735431 -0
  95. package/test/gcp-length.test.ts +344 -0
  96. package/test/gtin-creator.ts +4 -4
  97. package/test/gtin-validator.test.ts +205 -113
  98. package/test/gtin-validator.ts +30 -0
  99. package/test/identifier-creator.ts +6 -6
  100. package/test/non-numeric-identifier-creator.ts +0 -8
  101. package/test/non-serializable-numeric-identifier-creator.ts +4 -54
  102. package/test/numeric-identifier-creator.ts +4 -4
  103. package/test/prefix-manager.test.ts +5 -5
  104. package/test/serializable-numeric-identifier-creator.ts +32 -19
  105. package/test/validator.test.ts +6 -6
  106. package/test/variable-measure-rcn.test.ts +63 -68
  107. package/test/verified-by-gs1.test.ts +55 -0
  108. package/tsconfig-src.json +7 -1
  109. package/tsconfig-src.tsbuildinfo +1 -0
  110. package/tsconfig-tsup.json +7 -0
@@ -0,0 +1,380 @@
1
+ import { omit } from "@aidc-toolkit/core";
2
+ import type { GCPLengthCache } from "./gcp-length-cache.js";
3
+ import { type GCPLengthData, type GCPLengthHeader, isGCPLengthData } from "./gcp-length-data.js";
4
+ import { GTINLengths } from "./gtin-length.js";
5
+ import { GTINValidator } from "./gtin-validator.js";
6
+ import { type IdentifierType, IdentifierTypes } from "./identifier-type.js";
7
+ import { IdentifierValidators, isNumericIdentifierValidator } from "./identifier-validators.js";
8
+ import { LeaderTypes } from "./leader-type.js";
9
+
10
+ /**
11
+ * Leaf of GS1 Company Prefix length tree.
12
+ */
13
+ export interface Leaf {
14
+ length: number;
15
+ }
16
+
17
+ /**
18
+ * Branch of GS1 Company Prefix length tree.
19
+ */
20
+ export interface Branch {
21
+ childNodes: Array<Node | undefined>;
22
+ }
23
+
24
+ /**
25
+ * Root of GS1 Company Prefix length tree.
26
+ */
27
+ export interface Root extends GCPLengthHeader, Branch {
28
+ }
29
+
30
+ /**
31
+ * Node in GS1 Company Prefix length tree.
32
+ */
33
+ export type Node = Root | Branch | Leaf;
34
+
35
+ /**
36
+ * Determine if a node is a leaf.
37
+ *
38
+ * @param node
39
+ * Node.
40
+ *
41
+ * @returns
42
+ * True if node is a leaf.
43
+ */
44
+ export function isLeaf(node: Node): node is Leaf {
45
+ return "length" in node;
46
+ }
47
+
48
+ /**
49
+ * Entry in binary data to indicate that child node is undefined.
50
+ */
51
+ const BINARY_UNDEFINED = 0x0F;
52
+
53
+ /**
54
+ * Entry in binary data to indicate that child node is a branch.
55
+ */
56
+ const BINARY_BRANCH = 0x0E;
57
+
58
+ /**
59
+ * Build the GS1 Company Prefix length tree from a binary data array.
60
+ *
61
+ * @param binaryData
62
+ * Binary data array.
63
+ *
64
+ * @param childNodes
65
+ * Child nodes array to fill.
66
+ *
67
+ * @param startIndex
68
+ * Start index into binary data array.
69
+ *
70
+ * @returns
71
+ * End index into binary data array.
72
+ */
73
+ function fromBinary(binaryData: Uint8Array, childNodes: Array<Node | undefined>, startIndex: number): number {
74
+ let endIndex = startIndex;
75
+
76
+ const decompressedLengths = new Array<number>(10);
77
+
78
+ // Decompress lengths for the child nodes.
79
+ for (let childNodeIndex = 0; childNodeIndex < 10; childNodeIndex += 2) {
80
+ const byte = binaryData[endIndex++];
81
+
82
+ decompressedLengths[childNodeIndex] = byte >> 4;
83
+ decompressedLengths[childNodeIndex + 1] = byte & 0x0F;
84
+ }
85
+
86
+ for (let childNodeIndex = 0; childNodeIndex < 10; childNodeIndex++) {
87
+ const length = decompressedLengths[childNodeIndex];
88
+
89
+ if (length !== BINARY_UNDEFINED) {
90
+ let childNode: Node;
91
+
92
+ if (length === BINARY_BRANCH) {
93
+ childNode = {
94
+ childNodes: []
95
+ };
96
+
97
+ endIndex = fromBinary(binaryData, childNode.childNodes, endIndex);
98
+ } else {
99
+ childNode = {
100
+ length
101
+ };
102
+ }
103
+
104
+ // eslint-disable-next-line no-param-reassign -- Purpose is to build tree.
105
+ childNodes[childNodeIndex] = childNode;
106
+ }
107
+ }
108
+
109
+ return endIndex;
110
+ }
111
+
112
+ /**
113
+ * Add an entry to the tree by recursively walking the tree to a leaf.
114
+ *
115
+ * @param branch
116
+ * Current branch.
117
+ *
118
+ * @param prefix
119
+ * Remainder of current prefix.
120
+ *
121
+ * @param length
122
+ * Current prefix length.
123
+ *
124
+ * @returns
125
+ * Number of branches added; used to determine size of binary array.
126
+ */
127
+ function addEntry(branch: Branch, prefix: string, length: number): number {
128
+ const digit = Number(prefix.charAt(0));
129
+
130
+ const existingChildNode = branch.childNodes[digit];
131
+
132
+ let branchesAdded = 0;
133
+
134
+ if (prefix.length !== 1) {
135
+ let childBranch: Branch;
136
+
137
+ if (existingChildNode === undefined) {
138
+ childBranch = {
139
+ childNodes: []
140
+ };
141
+
142
+ branchesAdded++;
143
+ } else {
144
+ if (isLeaf(existingChildNode)) {
145
+ // File format error or application bug; localization not necessary.
146
+ throw new Error("Overlapping entry");
147
+ }
148
+
149
+ childBranch = existingChildNode;
150
+ }
151
+
152
+ // eslint-disable-next-line no-param-reassign -- Purpose is to build tree.
153
+ branch.childNodes[digit] = childBranch;
154
+
155
+ // Continue with remainder of prefix.
156
+ branchesAdded += addEntry(childBranch, prefix.substring(1), length);
157
+ } else {
158
+ if (existingChildNode !== undefined) {
159
+ // File format error or application bug; localization not necessary.
160
+ throw new Error("Duplicate entry");
161
+ }
162
+
163
+ // eslint-disable-next-line no-param-reassign -- Purpose is to build tree.
164
+ branch.childNodes[digit] = {
165
+ length
166
+ };
167
+ }
168
+
169
+ return branchesAdded;
170
+ }
171
+
172
+ /**
173
+ * Get the length of a child node if defined and it's a leaf, otherwise mark it with 0x0E if defined (branch) or 0x0F
174
+ * (no branch) if not.
175
+ *
176
+ * @param childNode
177
+ * Child node.
178
+ *
179
+ * @returns
180
+ * Child node length, 0x0E (branch), or 0x0F (undefined).
181
+ */
182
+ function childNodeValue(childNode: Node | undefined): number {
183
+ return childNode !== undefined ? isLeaf(childNode) ? childNode.length : BINARY_BRANCH : BINARY_UNDEFINED;
184
+ }
185
+
186
+ /**
187
+ * Add a branch to a binary data array.
188
+ *
189
+ * @param binaryData
190
+ * Binary data array.
191
+ *
192
+ * @param branch
193
+ * Branch.
194
+ *
195
+ * @param startIndex
196
+ * Start index into binary data array.
197
+ *
198
+ * @returns
199
+ * End index into binary data array.
200
+ */
201
+ function toBinary(binaryData: Uint8Array, branch: Branch, startIndex: number): number {
202
+ let endIndex = startIndex;
203
+
204
+ const childNodes = branch.childNodes;
205
+
206
+ // Add length or non-leaf indicators, compressing 10 nibbles into 5 bytes.
207
+ for (let childNodeIndex = 0; childNodeIndex < 10; childNodeIndex += 2) {
208
+ // eslint-disable-next-line no-param-reassign -- Purpose is to build array.
209
+ binaryData[endIndex++] = (childNodeValue(childNodes[childNodeIndex]) << 4) | childNodeValue(childNodes[childNodeIndex + 1]);
210
+ }
211
+
212
+ // Process child nodes.
213
+ for (const childNode of childNodes) {
214
+ if (childNode !== undefined && !isLeaf(childNode)) {
215
+ endIndex = toBinary(binaryData, childNode, endIndex);
216
+ }
217
+ }
218
+
219
+ return endIndex;
220
+ }
221
+
222
+ /**
223
+ * Add days to a date.
224
+ *
225
+ * @param date
226
+ * Date.
227
+ *
228
+ * @param days
229
+ * Days.
230
+ *
231
+ * @returns
232
+ * New date.
233
+ */
234
+ function addDays(date: Date, days: number): Date {
235
+ const futureDate = new Date(date);
236
+ futureDate.setDate(futureDate.getDate() + days);
237
+
238
+ return futureDate;
239
+ }
240
+
241
+ /**
242
+ * Load the GS1 Company Prefix length data.
243
+ *
244
+ * @param gcpLengthCache
245
+ * GS1 Company Prefix length cache.
246
+ *
247
+ * @returns
248
+ * Root of tree.
249
+ */
250
+ export async function loadData(gcpLengthCache: GCPLengthCache): Promise<Root | undefined> {
251
+ let root: Root | undefined = undefined;
252
+
253
+ let nextCheckDateTime = await gcpLengthCache.nextCheckDateTime;
254
+ let cacheDateTime = await gcpLengthCache.cacheDateTime;
255
+
256
+ const now = new Date();
257
+ const tomorrow = addDays(now, 1);
258
+
259
+ if (nextCheckDateTime === undefined || nextCheckDateTime.getTime() <= now.getTime()) {
260
+ const sourceDateTime = await gcpLengthCache.sourceDateTime;
261
+
262
+ if (cacheDateTime === undefined || cacheDateTime.getTime() < sourceDateTime.getTime()) {
263
+ const sourceData = await gcpLengthCache.sourceData;
264
+
265
+ let cacheData: GCPLengthData;
266
+
267
+ if (isGCPLengthData(sourceData)) {
268
+ root = {
269
+ dateTime: sourceData.dateTime,
270
+ disclaimer: sourceData.disclaimer,
271
+ childNodes: []
272
+ };
273
+
274
+ fromBinary(sourceData.data, root.childNodes, 0);
275
+
276
+ cacheData = sourceData;
277
+ } else {
278
+ root = {
279
+ dateTime: new Date(sourceData.GCPPrefixFormatList.date),
280
+ // Join disclaimer as a single string.
281
+ disclaimer: `${sourceData._disclaimer.reduce<string[]>((lines, line) => {
282
+ if (lines.length === 0 || lines[lines.length - 1] === "" || line === "") {
283
+ lines.push(line);
284
+ } else {
285
+ // Lines are part of the same paragraph.
286
+ lines.push(`${lines.pop()} ${line}`);
287
+ }
288
+
289
+ return lines;
290
+ }, []).join("\n")}\n`,
291
+ childNodes: []
292
+ };
293
+
294
+ let branchesAdded = 1;
295
+
296
+ for (const entry of sourceData.GCPPrefixFormatList.entry) {
297
+ branchesAdded += addEntry(root, entry.prefix, entry.gcpLength);
298
+ }
299
+
300
+ // Each branch has ten (some possibly undefined) entries, two per byte.
301
+ const data = new Uint8Array(branchesAdded * 5);
302
+
303
+ toBinary(data, root, 0);
304
+
305
+ cacheData = {
306
+ ...omit(root, "childNodes"),
307
+ data
308
+ };
309
+ }
310
+
311
+ // Next check date/time is a week from source date/time or tomorrow, whichever is later.
312
+ nextCheckDateTime = addDays(sourceDateTime, 7);
313
+ if (nextCheckDateTime.getTime() < tomorrow.getTime()) {
314
+ nextCheckDateTime = tomorrow;
315
+ }
316
+
317
+ cacheDateTime = sourceDateTime;
318
+
319
+ await gcpLengthCache.update(nextCheckDateTime, cacheDateTime, cacheData);
320
+ } else {
321
+ // Next check date/time is tomorrow.
322
+ await gcpLengthCache.update(tomorrow);
323
+ }
324
+ }
325
+
326
+ // Root is undefined if cache data is still valid or retrying after prior failure.
327
+ if (root === undefined && cacheDateTime !== undefined) {
328
+ const cacheData = await gcpLengthCache.cacheData;
329
+
330
+ root = {
331
+ ...omit(cacheData, "data"),
332
+ childNodes: []
333
+ };
334
+
335
+ fromBinary(cacheData.data, root.childNodes, 0);
336
+ }
337
+
338
+ return root;
339
+ }
340
+
341
+ /**
342
+ * Get the length of a GS1 Company Prefix for an identifier.
343
+ *
344
+ * @param root
345
+ * Root of tree.
346
+ *
347
+ * @param identifierType
348
+ * Identifier type.
349
+ *
350
+ * @param identifier
351
+ * Identifier.
352
+ *
353
+ * @returns
354
+ * Length of GS1 Company Prefix, 0 if not a GS1 Company Prefix, or -1 if not found.
355
+ */
356
+ export function getFor(root: Root, identifierType: IdentifierType, identifier: string): number {
357
+ let identifierPrefix: string;
358
+
359
+ if (identifierType === IdentifierTypes.GTIN) {
360
+ // Normalize the GTIN, pad to 14 digits, and extract the identifier prefix at the first character.
361
+ identifierPrefix = GTINValidator.normalize(identifier).padStart(GTINLengths.GTIN14, "0").substring(1);
362
+ } else {
363
+ const identifierValidator = IdentifierValidators[identifierType];
364
+
365
+ identifierValidator.validate(identifier);
366
+
367
+ identifierPrefix = !isNumericIdentifierValidator(identifierValidator) || identifierValidator.leaderType !== LeaderTypes.ExtensionDigit ? identifier : identifier.substring(1);
368
+ }
369
+
370
+ let node: Node | undefined = root;
371
+
372
+ let digitIndex = 0;
373
+
374
+ // Traverse tree until exhausted or at a leaf.
375
+ while (node !== undefined && !isLeaf(node)) {
376
+ node = node.childNodes[Number(identifierPrefix.charAt(digitIndex++))];
377
+ }
378
+
379
+ return node?.length ?? -1;
380
+ }
@@ -6,7 +6,7 @@ import {
6
6
  type TransformerOutput
7
7
  } from "@aidc-toolkit/utility";
8
8
  import { MixinAbstractNumericIdentifierCreator } from "./abstract-numeric-identifier-creator.js";
9
- import { checkDigit, priceOrWeightCheckDigit } from "./check.js";
9
+ import { checkDigit } from "./check.js";
10
10
  import { type GTINBaseLength, GTINLengths } from "./gtin-length.js";
11
11
  import type { GTINType } from "./gtin-type.js";
12
12
  import { GTINValidator } from "./gtin-validator.js";
@@ -76,120 +76,4 @@ export class GTINCreator extends MixinAbstractNumericIdentifierCreator<
76
76
  return partialIdentifier + checkDigit(partialIdentifier);
77
77
  });
78
78
  }
79
-
80
- /**
81
- * Create a Restricted Circulation Number (RCN) using a variable measure trade item format. See {@linkcode
82
- * GTINValidator.parseVariableMeasureRCN} for format details.
83
- *
84
- * @param format
85
- * Format.
86
- *
87
- * @param itemReference
88
- * Item reference.
89
- *
90
- * @param priceOrWeight
91
- * Price or weight (whole number only).
92
- *
93
- * @returns
94
- * RCN-12 or RCN-13.
95
- */
96
- static createVariableMeasureRCN(format: string, itemReference: number, priceOrWeight: number): string {
97
- const formatLength = format.length;
98
-
99
- let validFormat = formatLength === 12 || formatLength === 13;
100
-
101
- let rcnPrefix = "";
102
-
103
- let buildingItemReference = false;
104
- let itemReferenceString = "";
105
- let itemReferenceLength = 0;
106
-
107
- let buildingPriceOrWeight = false;
108
- let priceOrWeightString = "";
109
- let priceOrWeightLength = 0;
110
-
111
- let calculatePriceOrWeightCheckDigit = false;
112
-
113
- // RCN may be built in almost any order, so defer to builders that will be in ordered array.
114
- const rcnPrefixBuilder = (partialRCN: string): string => partialRCN + rcnPrefix;
115
- const itemReferenceBuilder = (partialRCN: string): string => partialRCN + itemReferenceString;
116
- const priceOrWeightBuilder = (partialRCN: string): string => partialRCN + priceOrWeightString;
117
- const priceOrWeightCheckDigitBuilder = (partialRCN: string): string => partialRCN + priceOrWeightCheckDigit(priceOrWeightString);
118
- const checkDigitBuilder = (partialRCN: string): string => partialRCN + checkDigit(partialRCN);
119
-
120
- const rcnBuilders = [rcnPrefixBuilder];
121
-
122
- for (let index = 0; validFormat && index < formatLength; index++) {
123
- const formatChar = format.charAt(index);
124
-
125
- if (index === 0) {
126
- validFormat = formatChar === "2";
127
- rcnPrefix = formatChar;
128
- } else if (formatLength === 13 && index === 1) {
129
- validFormat = NUMERIC_CREATOR.characterIndex(formatChar) !== undefined;
130
- rcnPrefix += formatChar;
131
- } else if (index === formatLength - 1) {
132
- validFormat = formatChar === "C";
133
- } else {
134
- switch (formatChar) {
135
- case "I":
136
- if (!buildingItemReference) {
137
- // Item reference can't appear more than once.
138
- validFormat = itemReferenceLength === 0;
139
-
140
- buildingItemReference = true;
141
- buildingPriceOrWeight = false;
142
-
143
- rcnBuilders.push(itemReferenceBuilder);
144
- }
145
-
146
- itemReferenceLength++;
147
- break;
148
-
149
- case "P":
150
- if (!buildingPriceOrWeight) {
151
- // Price or weight can't appear more than once.
152
- validFormat = priceOrWeightLength === 0;
153
-
154
- buildingPriceOrWeight = true;
155
- buildingItemReference = false;
156
-
157
- rcnBuilders.push(priceOrWeightBuilder);
158
- }
159
-
160
- priceOrWeightLength++;
161
- break;
162
-
163
- case "V":
164
- // Price or weight check digit can't appear more than once.
165
- validFormat = !calculatePriceOrWeightCheckDigit;
166
-
167
- buildingItemReference = false;
168
- buildingPriceOrWeight = false;
169
-
170
- calculatePriceOrWeightCheckDigit = true;
171
-
172
- rcnBuilders.push(priceOrWeightCheckDigitBuilder);
173
- break;
174
-
175
- default:
176
- validFormat = false;
177
- break;
178
- }
179
- }
180
- }
181
-
182
- validFormat &&= itemReferenceLength !== 0 && priceOrWeightLength !== 0;
183
-
184
- if (!validFormat) {
185
- throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNFormat"));
186
- }
187
-
188
- itemReferenceString = NUMERIC_CREATOR.create(itemReferenceLength, itemReference);
189
- priceOrWeightString = NUMERIC_CREATOR.create(priceOrWeightLength, priceOrWeight);
190
-
191
- rcnBuilders.push(checkDigitBuilder);
192
-
193
- return rcnBuilders.reduce((partialRCN, rcnBuilder) => rcnBuilder(partialRCN), "");
194
- }
195
79
  }