@aidc-toolkit/gs1 1.0.22-beta → 1.0.24-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 (133) hide show
  1. package/dist/index.cjs +4624 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +1588 -0
  4. package/dist/index.d.ts +1588 -36
  5. package/dist/index.js +4541 -19
  6. package/dist/index.js.map +1 -1
  7. package/package.json +4 -8
  8. package/src/character-set.ts +16 -1
  9. package/src/check.ts +2 -2
  10. package/src/gtin-creator.ts +4 -4
  11. package/src/gtin-validator.ts +6 -6
  12. package/src/identifier-creator.ts +3 -3
  13. package/src/identifier-validator.ts +4 -4
  14. package/src/index.ts +19 -19
  15. package/src/locale/en/{locale-strings.ts → locale-resources.ts} +1 -1
  16. package/src/locale/fr/{locale-strings.ts → locale-resources.ts} +2 -2
  17. package/src/locale/i18n.ts +6 -8
  18. package/src/locale/i18next.d.ts +4 -4
  19. package/src/non-gtin-numeric-identifier-creator.ts +4 -4
  20. package/src/non-gtin-numeric-identifier-validator.ts +3 -3
  21. package/src/non-numeric-identifier-creator.ts +6 -6
  22. package/src/non-numeric-identifier-validator.ts +6 -6
  23. package/src/numeric-identifier-creator.ts +3 -3
  24. package/src/numeric-identifier-validator.ts +5 -5
  25. package/src/prefix-manager.ts +36 -35
  26. package/src/prefix-provider.ts +1 -1
  27. package/src/prefix-validator.ts +2 -2
  28. package/src/serializable-numeric-identifier-creator.ts +4 -4
  29. package/src/serializable-numeric-identifier-validator.ts +5 -5
  30. package/test/creator.test.ts +3 -3
  31. package/test/gtin-creator.ts +1 -1
  32. package/test/gtin-validator.test.ts +1 -1
  33. package/test/identifier-creator.ts +4 -4
  34. package/test/non-gtin-numeric-identifier-creator.ts +1 -1
  35. package/test/non-gtin-numeric-identifier-validator.ts +1 -1
  36. package/test/non-numeric-identifier-validator.ts +2 -2
  37. package/test/numeric-identifier-creator.ts +1 -1
  38. package/test/numeric-identifier-validator.ts +1 -1
  39. package/test/prefix-manager.test.ts +1 -1
  40. package/test/serializable-numeric-identifier-creator.ts +1 -1
  41. package/test/serializable-numeric-identifier-validator.ts +2 -2
  42. package/test/validator.test.ts +4 -4
  43. package/tsup.config.ts +3 -0
  44. package/typedoc.json +1 -3
  45. package/dist/character-set.d.ts +0 -22
  46. package/dist/character-set.d.ts.map +0 -1
  47. package/dist/character-set.js +0 -36
  48. package/dist/character-set.js.map +0 -1
  49. package/dist/check.d.ts +0 -81
  50. package/dist/check.d.ts.map +0 -1
  51. package/dist/check.js +0 -218
  52. package/dist/check.js.map +0 -1
  53. package/dist/gtin-creator.d.ts +0 -68
  54. package/dist/gtin-creator.d.ts.map +0 -1
  55. package/dist/gtin-creator.js +0 -158
  56. package/dist/gtin-creator.js.map +0 -1
  57. package/dist/gtin-validator.d.ts +0 -202
  58. package/dist/gtin-validator.d.ts.map +0 -1
  59. package/dist/gtin-validator.js +0 -470
  60. package/dist/gtin-validator.js.map +0 -1
  61. package/dist/identifier-creator.d.ts +0 -72
  62. package/dist/identifier-creator.d.ts.map +0 -1
  63. package/dist/identifier-creator.js +0 -50
  64. package/dist/identifier-creator.js.map +0 -1
  65. package/dist/identifier-type.d.ts +0 -58
  66. package/dist/identifier-type.d.ts.map +0 -1
  67. package/dist/identifier-type.js +0 -54
  68. package/dist/identifier-type.js.map +0 -1
  69. package/dist/identifier-validator.d.ts +0 -174
  70. package/dist/identifier-validator.d.ts.map +0 -1
  71. package/dist/identifier-validator.js +0 -145
  72. package/dist/identifier-validator.js.map +0 -1
  73. package/dist/index.d.ts.map +0 -1
  74. package/dist/locale/en/locale-strings.d.ts +0 -42
  75. package/dist/locale/en/locale-strings.d.ts.map +0 -1
  76. package/dist/locale/en/locale-strings.js +0 -42
  77. package/dist/locale/en/locale-strings.js.map +0 -1
  78. package/dist/locale/fr/locale-strings.d.ts +0 -42
  79. package/dist/locale/fr/locale-strings.d.ts.map +0 -1
  80. package/dist/locale/fr/locale-strings.js +0 -42
  81. package/dist/locale/fr/locale-strings.js.map +0 -1
  82. package/dist/locale/i18n.d.ts +0 -27
  83. package/dist/locale/i18n.d.ts.map +0 -1
  84. package/dist/locale/i18n.js +0 -37
  85. package/dist/locale/i18n.js.map +0 -1
  86. package/dist/non-gtin-numeric-identifier-creator.d.ts +0 -30
  87. package/dist/non-gtin-numeric-identifier-creator.d.ts.map +0 -1
  88. package/dist/non-gtin-numeric-identifier-creator.js +0 -30
  89. package/dist/non-gtin-numeric-identifier-creator.js.map +0 -1
  90. package/dist/non-gtin-numeric-identifier-validator.d.ts +0 -41
  91. package/dist/non-gtin-numeric-identifier-validator.d.ts.map +0 -1
  92. package/dist/non-gtin-numeric-identifier-validator.js +0 -40
  93. package/dist/non-gtin-numeric-identifier-validator.js.map +0 -1
  94. package/dist/non-numeric-identifier-creator.d.ts +0 -55
  95. package/dist/non-numeric-identifier-creator.d.ts.map +0 -1
  96. package/dist/non-numeric-identifier-creator.js +0 -93
  97. package/dist/non-numeric-identifier-creator.js.map +0 -1
  98. package/dist/non-numeric-identifier-validator.d.ts +0 -78
  99. package/dist/non-numeric-identifier-validator.d.ts.map +0 -1
  100. package/dist/non-numeric-identifier-validator.js +0 -95
  101. package/dist/non-numeric-identifier-validator.js.map +0 -1
  102. package/dist/numeric-identifier-creator.d.ts +0 -121
  103. package/dist/numeric-identifier-creator.d.ts.map +0 -1
  104. package/dist/numeric-identifier-creator.js +0 -135
  105. package/dist/numeric-identifier-creator.js.map +0 -1
  106. package/dist/numeric-identifier-validator.d.ts +0 -76
  107. package/dist/numeric-identifier-validator.d.ts.map +0 -1
  108. package/dist/numeric-identifier-validator.js +0 -84
  109. package/dist/numeric-identifier-validator.js.map +0 -1
  110. package/dist/prefix-manager.d.ts +0 -224
  111. package/dist/prefix-manager.d.ts.map +0 -1
  112. package/dist/prefix-manager.js +0 -369
  113. package/dist/prefix-manager.js.map +0 -1
  114. package/dist/prefix-provider.d.ts +0 -27
  115. package/dist/prefix-provider.d.ts.map +0 -1
  116. package/dist/prefix-provider.js +0 -2
  117. package/dist/prefix-provider.js.map +0 -1
  118. package/dist/prefix-type.d.ts +0 -22
  119. package/dist/prefix-type.d.ts.map +0 -1
  120. package/dist/prefix-type.js +0 -18
  121. package/dist/prefix-type.js.map +0 -1
  122. package/dist/prefix-validator.d.ts +0 -58
  123. package/dist/prefix-validator.d.ts.map +0 -1
  124. package/dist/prefix-validator.js +0 -154
  125. package/dist/prefix-validator.js.map +0 -1
  126. package/dist/serializable-numeric-identifier-creator.d.ts +0 -86
  127. package/dist/serializable-numeric-identifier-creator.d.ts.map +0 -1
  128. package/dist/serializable-numeric-identifier-creator.js +0 -116
  129. package/dist/serializable-numeric-identifier-creator.js.map +0 -1
  130. package/dist/serializable-numeric-identifier-validator.d.ts +0 -79
  131. package/dist/serializable-numeric-identifier-validator.d.ts.map +0 -1
  132. package/dist/serializable-numeric-identifier-validator.js +0 -99
  133. package/dist/serializable-numeric-identifier-validator.js.map +0 -1
@@ -1,158 +0,0 @@
1
- import { Exclusions, NUMERIC_CREATOR } from "@aidc-toolkit/utility";
2
- import { Mixin } from "ts-mixer";
3
- import { checkDigit, priceOrWeightCheckDigit } from "./check.js";
4
- import { GTINTypes, GTINValidator } from "./gtin-validator.js";
5
- import { i18nextGS1 } from "./locale/i18n.js";
6
- import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
7
- /**
8
- * GTIN creator. Applicable to GTIN-13, GTIN-12, and GTIN-8 types; no applicable to GTIN-14 type.
9
- */
10
- export class GTINCreator extends Mixin(GTINValidator, AbstractNumericIdentifierCreator) {
11
- /**
12
- * Validation parameters for required indicator digit.
13
- */
14
- static REQUIRED_INDICATOR_DIGIT_VALIDATION = {
15
- minimumLength: 1,
16
- maximumLength: 1,
17
- component: () => i18nextGS1.t("Identifier.indicatorDigit")
18
- };
19
- /**
20
- * Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
21
- * provider type.
22
- *
23
- * @param prefixProvider
24
- * Prefix provider.
25
- *
26
- * @param gtinType
27
- * GTIN type.
28
- */
29
- constructor(prefixProvider, gtinType) {
30
- super(gtinType);
31
- this.init(prefixProvider, prefixProvider.prefix);
32
- }
33
- /**
34
- * @inheritDoc
35
- */
36
- get prefix() {
37
- return this.prefixProvider.prefix;
38
- }
39
- /**
40
- * Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
41
- * converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
42
- *
43
- * @template TTransformerInput
44
- * Transformer input type.
45
- *
46
- * @param indicatorDigit
47
- * Indicator digit.
48
- *
49
- * @param valueOrValues
50
- * Numeric value(s).
51
- *
52
- * @param sparse
53
- * If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
54
- *
55
- * @returns
56
- * GTIN-14(s).
57
- */
58
- createGTIN14(indicatorDigit, valueOrValues, sparse = false) {
59
- NUMERIC_CREATOR.validate(indicatorDigit, GTINCreator.REQUIRED_INDICATOR_DIGIT_VALIDATION);
60
- return NUMERIC_CREATOR.create(GTINTypes.GTIN13 - this.prefixProvider.gs1CompanyPrefix.length - 1, valueOrValues, Exclusions.None, sparse ? this.tweak : undefined, (reference) => {
61
- const partialIdentifier = indicatorDigit + this.prefixProvider.gs1CompanyPrefix + reference;
62
- return partialIdentifier + checkDigit(partialIdentifier);
63
- });
64
- }
65
- /**
66
- * Create a Restricted Circulation Number (RCN) using a variable measure trade item format. See {@linkcode
67
- * GTINValidator.parseVariableMeasureRCN} for format details.
68
- *
69
- * @param format
70
- * Format.
71
- *
72
- * @param itemReference
73
- * Item reference.
74
- *
75
- * @param priceOrWeight
76
- * Price or weight (whole number only).
77
- *
78
- * @returns
79
- * RCN-12 or RCN-13.
80
- */
81
- static createVariableMeasureRCN(format, itemReference, priceOrWeight) {
82
- const formatLength = format.length;
83
- let validFormat = formatLength === 12 || formatLength === 13;
84
- let rcnPrefix = "";
85
- let buildingItemReference = false;
86
- let itemReferenceString = "";
87
- let itemReferenceLength = 0;
88
- let buildingPriceOrWeight = false;
89
- let priceOrWeightString = "";
90
- let priceOrWeightLength = 0;
91
- let calculatePriceOrWeightCheckDigit = false;
92
- // RCN may be built in almost any order, so defer to builders that will be in ordered array.
93
- const rcnPrefixBuilder = (partialRCN) => partialRCN + rcnPrefix;
94
- const itemReferenceBuilder = (partialRCN) => partialRCN + itemReferenceString;
95
- const priceOrWeightBuilder = (partialRCN) => partialRCN + priceOrWeightString;
96
- const priceOrWeightCheckDigitBuilder = (partialRCN) => partialRCN + priceOrWeightCheckDigit(priceOrWeightString);
97
- const checkDigitBuilder = (partialRCN) => partialRCN + checkDigit(partialRCN);
98
- const rcnBuilders = [rcnPrefixBuilder];
99
- for (let index = 0; validFormat && index < formatLength; index++) {
100
- const formatChar = format.charAt(index);
101
- if (index === 0) {
102
- validFormat = formatChar === "2";
103
- rcnPrefix = formatChar;
104
- }
105
- else if (formatLength === 13 && index === 1) {
106
- validFormat = NUMERIC_CREATOR.characterIndex(formatChar) !== undefined;
107
- rcnPrefix += formatChar;
108
- }
109
- else if (index === formatLength - 1) {
110
- validFormat = formatChar === "C";
111
- }
112
- else {
113
- switch (formatChar) {
114
- case "I":
115
- if (!buildingItemReference) {
116
- // Item reference can't appear more than once.
117
- validFormat = itemReferenceLength === 0;
118
- buildingItemReference = true;
119
- buildingPriceOrWeight = false;
120
- rcnBuilders.push(itemReferenceBuilder);
121
- }
122
- itemReferenceLength++;
123
- break;
124
- case "P":
125
- if (!buildingPriceOrWeight) {
126
- // Price or weight can't appear more than once.
127
- validFormat = priceOrWeightLength === 0;
128
- buildingPriceOrWeight = true;
129
- buildingItemReference = false;
130
- rcnBuilders.push(priceOrWeightBuilder);
131
- }
132
- priceOrWeightLength++;
133
- break;
134
- case "V":
135
- // Price or weight check digit can't appear more than once.
136
- validFormat = !calculatePriceOrWeightCheckDigit;
137
- buildingItemReference = false;
138
- buildingPriceOrWeight = false;
139
- calculatePriceOrWeightCheckDigit = true;
140
- rcnBuilders.push(priceOrWeightCheckDigitBuilder);
141
- break;
142
- default:
143
- validFormat = false;
144
- break;
145
- }
146
- }
147
- }
148
- validFormat &&= itemReferenceLength !== 0 && priceOrWeightLength !== 0;
149
- if (!validFormat) {
150
- throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNFormat"));
151
- }
152
- itemReferenceString = NUMERIC_CREATOR.create(itemReferenceLength, itemReference);
153
- priceOrWeightString = NUMERIC_CREATOR.create(priceOrWeightLength, priceOrWeight);
154
- rcnBuilders.push(checkDigitBuilder);
155
- return rcnBuilders.reduce((partialRCN, rcnBuilder) => rcnBuilder(partialRCN), "");
156
- }
157
- }
158
- //# sourceMappingURL=gtin-creator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gtin-creator.js","sourceRoot":"","sources":["../src/gtin-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EACV,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAiB,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAGnF;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,aAAa,EAAE,gCAAgC,CAAC;IACnF;;OAEG;IACK,MAAM,CAAU,mCAAmC,GAA2B;QAClF,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,CAAC;QAChB,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,2BAA2B,CAAC;KAC7D,CAAC;IAEF;;;;;;;;;OASG;IACH,YAAY,cAA8B,EAAE,QAAkB;QAC1D,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,IAAI,CAAC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AAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;QAEjF,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEpC,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC"}
@@ -1,202 +0,0 @@
1
- import { AbstractNumericIdentifierValidator } from "./numeric-identifier-validator.js";
2
- import { type PrefixType } from "./prefix-type.js";
3
- /**
4
- * GTIN types. The numeric values are equal to the lengths of the GTIN types.
5
- */
6
- export declare const GTINTypes: {
7
- /**
8
- * GTIN-13.
9
- */
10
- readonly GTIN13: 13;
11
- /**
12
- * GTIN-12.
13
- */
14
- readonly GTIN12: 12;
15
- /**
16
- * GTIN-8.
17
- */
18
- readonly GTIN8: 8;
19
- /**
20
- * GTIN-14.
21
- */
22
- readonly GTIN14: 14;
23
- };
24
- /**
25
- * GTIN type.
26
- */
27
- export type GTINType = typeof GTINTypes[keyof typeof GTINTypes];
28
- /**
29
- * Levels at which GTIN is to be validated.
30
- */
31
- export declare const GTINLevels: {
32
- /**
33
- * Any level (level is ignored).
34
- */
35
- readonly Any: 0;
36
- /**
37
- * Retail consumer trade item level, supporting GTIN-13, GTIN-12 (optionally zero-suppressed), and GTIN-8.
38
- */
39
- readonly RetailConsumer: 1;
40
- /**
41
- * Other than retail consumer trade item level, supporting GTIN-13, GTIN-12 (not zero-suppressed), and GTIN-14.
42
- */
43
- readonly OtherThanRetailConsumer: 2;
44
- };
45
- /**
46
- * GTIN level.
47
- */
48
- export type GTINLevel = typeof GTINLevels[keyof typeof GTINLevels];
49
- /**
50
- * Restricted Circulation Number reference.
51
- */
52
- export interface RCNReference {
53
- /**
54
- * Item reference.
55
- */
56
- itemReference: number;
57
- /**
58
- * Price or weight (whole number only).
59
- */
60
- priceOrWeight: number;
61
- }
62
- /**
63
- * GTIN validator.
64
- */
65
- export declare class GTINValidator extends AbstractNumericIdentifierValidator {
66
- /**
67
- * Validation parameters for optional indicator digit.
68
- */
69
- private static readonly OPTIONAL_INDICATOR_DIGIT_VALIDATION;
70
- /**
71
- * Validation parameters for zero-suppressed GTIN-12.
72
- */
73
- private static readonly ZERO_SUPPRESSED_GTIN12_VALIDATION;
74
- /**
75
- * Constructor.
76
- *
77
- * @param gtinType
78
- * GTIN type.
79
- */
80
- constructor(gtinType: GTINType);
81
- /**
82
- * @inheritDoc
83
- */
84
- get gtinType(): GTINType;
85
- /**
86
- * @inheritDoc
87
- */
88
- protected validatePrefix(partialIdentifier: string, positionOffset?: number): void;
89
- /**
90
- * Zero suppress a GTIN-12.
91
- *
92
- * @param gtin12
93
- * GTIN-12.
94
- *
95
- * @returns
96
- * Zero-suppressed GTIN-12.
97
- */
98
- static zeroSuppress(gtin12: string): string;
99
- /**
100
- * Zero expand a zero-suppressed GTIN-12.
101
- *
102
- * @param zeroSuppressedGTIN12
103
- * Zero-suppressed GTIN-12.
104
- *
105
- * @returns
106
- * GTIN-12.
107
- */
108
- static zeroExpand(zeroSuppressedGTIN12: string): string;
109
- /**
110
- * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
111
- *
112
- * @param indicatorDigit
113
- * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
114
- *
115
- * @param gtin
116
- * GTIN.
117
- *
118
- * @returns
119
- * GTIN-14.
120
- */
121
- static convertToGTIN14(indicatorDigit: string, gtin: string): string;
122
- /**
123
- * Normalize a GTIN of any length.
124
- * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
125
- * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
126
- * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
127
- * - Otherwise, the GTIN is unchanged.
128
- *
129
- * @param gtin
130
- * GTIN.
131
- *
132
- * @returns
133
- * Normalized GTIN.
134
- */
135
- static normalize(gtin: string): string;
136
- /**
137
- * Validate any GTIN, optionally against a level.
138
- *
139
- * @param gtin
140
- * GTIN.
141
- *
142
- * @param gtinLevel
143
- * Level at which GTIN is to be validated.
144
- */
145
- static validateAny(gtin: string, gtinLevel?: GTINLevel): void;
146
- /**
147
- * Validate a GTIN-14.
148
- *
149
- * @param gtin14
150
- * GTIN-14.
151
- */
152
- static validateGTIN14(gtin14: string): void;
153
- /**
154
- * Parse a Restricted Circulation Number (RCN) using a variable measure trade item format. The format is a 12- or
155
- * 13-character string (for RCN-12 or RCN-13 respectively), containing the following:
156
- *
157
- * - '2' - The first character of the RCN.
158
- * - '0'-'9' - The second character of the RCN (RCN-13 only).
159
- * - 'I' - One or more, in sequence, for the item reference.
160
- * - 'P' - One or more, in sequence, for the price or weight.
161
- * - 'V' - Zero or one, for the price or weight check digit.
162
- * - 'C' - The check digit of the entire RCN.
163
- *
164
- * The 'I', 'P', and 'V' formats may be in any order.
165
- *
166
- * Some examples:
167
- *
168
- * - 2IIIIIVPPPPC - RCN-12 with a five-digit item reference, a price or weight check digit, and a four-digit price
169
- * or weight.
170
- * - 23IIIIVPPPPPC - RCN-13 with a four-digit item reference, a price or weight check digit, and a five-digit price
171
- * or weight.
172
- * - 2IIIIIIPPPPC - RCN-12 with a six-digit item reference and a four-digit price or eight.
173
- * - 29IIIIIPPPPPC - RCN-13 with a five-digit item reference and a five-digit price or weight.
174
- *
175
- * @param format
176
- * Format.
177
- *
178
- * @param rcn
179
- * RCN.
180
- *
181
- * @returns
182
- * RCN reference.
183
- */
184
- static parseVariableMeasureRCN(format: string, rcn: string): RCNReference;
185
- }
186
- /**
187
- * GTIN-13 validator.
188
- */
189
- export declare const GTIN13_VALIDATOR: GTINValidator;
190
- /**
191
- * GTIN-12 validator.
192
- */
193
- export declare const GTIN12_VALIDATOR: GTINValidator;
194
- /**
195
- * GTIN-8 validator.
196
- */
197
- export declare const GTIN8_VALIDATOR: GTINValidator;
198
- /**
199
- * GTIN validators indexed by prefix type.
200
- */
201
- export declare const GTIN_VALIDATORS: Record<PrefixType, GTINValidator>;
202
- //# sourceMappingURL=gtin-validator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gtin-validator.d.ts","sourceRoot":"","sources":["../src/gtin-validator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kCAAkC,EAAe,MAAM,mCAAmC,CAAC;AACpG,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAGhE;;GAEG;AACH,eAAO,MAAM,SAAS;IAClB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,SAAS,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,UAAU;IACnB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,kCAAkC;IACjE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mCAAmC,CAIzD;IAEF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iCAAiC,CAGvD;IAEF;;;;;OAKG;gBACS,QAAQ,EAAE,QAAQ;IAyB9B;;OAEG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAGvB;IAED;;OAEG;cACgB,cAAc,CAAC,iBAAiB,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IAK3F;;;;;;;;OAQG;IACH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;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