@aidc-toolkit/gs1 0.9.15-beta → 0.9.17-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.
- package/dist/character-set.js +26 -0
- package/dist/character-set.js.map +1 -0
- package/dist/check.js +211 -0
- package/dist/check.js.map +1 -0
- package/dist/idkey.js +1809 -0
- package/dist/idkey.js.map +1 -0
- package/dist/index.js +5 -1978
- package/dist/index.js.map +1 -0
- package/dist/locale/en/locale-strings.js +38 -0
- package/dist/locale/en/locale-strings.js.map +1 -0
- package/dist/locale/fr/locale-strings.js +38 -0
- package/dist/locale/fr/locale-strings.js.map +1 -0
- package/dist/locale/i18n.js +37 -0
- package/dist/locale/i18n.js.map +1 -0
- package/gs1.iml +9 -0
- package/package.json +8 -10
- package/test/check.test.ts +1 -1
- package/test/idkey.test.ts +32 -32
- package/typedoc.json +1 -3
- package/dist/index.cjs +0 -2067
- package/dist/index.d.cts +0 -1497
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const localeStrings = {
|
|
2
|
+
Check: {
|
|
3
|
+
lengthOfStringForPriceOrWeightMustBeExactly: "Length {{length}} of string for price or weight sum must be exactly {{exactLength}}",
|
|
4
|
+
priceOrWeightComponent: "price or weight",
|
|
5
|
+
lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "Length {{length}} of string for check character pair must be less than or equal to {{maximumLength}}"
|
|
6
|
+
},
|
|
7
|
+
IdentificationKey: {
|
|
8
|
+
identificationKeyTypeLength: "{{identificationKeyType}} must be {{length}} digits long",
|
|
9
|
+
invalidCheckDigit: "Invalid check digit",
|
|
10
|
+
invalidGTINLength: "GTIN must be 13, 12, 8, or 14 digits long",
|
|
11
|
+
invalidGTIN14Length: "GTIN must be 14 digits long",
|
|
12
|
+
invalidZeroSuppressedGTIN12: "Invalid zero-suppressed GTIN-12",
|
|
13
|
+
invalidZeroSuppressibleGTIN12: "GTIN-12 not zero-suppressible",
|
|
14
|
+
invalidZeroSuppressedGTIN12AsGTIN13: "Invalid zero-suppressed GTIN-12 as GTIN-13",
|
|
15
|
+
invalidZeroSuppressedGTIN12AsGTIN14: "Invalid zero-suppressed GTIN-12 as GTIN-14",
|
|
16
|
+
invalidGTIN13AtRetail: "GTIN-13 at retail consumer trade item level can't start with zero",
|
|
17
|
+
invalidGTINAtRetail: "GTIN not supported at retail consumer trade item level",
|
|
18
|
+
invalidGTINAtOtherThanRetail: "GTIN not supported at other than retail consumer trade item level",
|
|
19
|
+
indicatorDigit: "indicator digit",
|
|
20
|
+
serialComponent: "serial component",
|
|
21
|
+
reference: "reference",
|
|
22
|
+
referenceCantBeAllNumeric: "Reference can't be all-numeric",
|
|
23
|
+
invalidCheckCharacterPair: "Invalid check character pair"
|
|
24
|
+
},
|
|
25
|
+
Prefix: {
|
|
26
|
+
gs1CompanyPrefix: "GS1 Company Prefix",
|
|
27
|
+
upcCompanyPrefix: "U.P.C. Company Prefix",
|
|
28
|
+
gs18Prefix: "GS1-8 Prefix",
|
|
29
|
+
invalidPrefixType: "Invalid prefix type",
|
|
30
|
+
gs1CompanyPrefixCantStartWith0: "GS1 Company Prefix can't start with \"0\"",
|
|
31
|
+
gs1CompanyPrefixCantStartWith00000: "GS1 Company Prefix can't start with \"00000\"",
|
|
32
|
+
gs1CompanyPrefixCantStartWith000000: "GS1 Company Prefix can't start with \"000000\"",
|
|
33
|
+
upcCompanyPrefixCantStartWith0000: "U.P.C. Company Prefix can't start with \"0000\"",
|
|
34
|
+
gs18PrefixCantStartWith0: "GS1-8 Prefix can't start with \"0\"",
|
|
35
|
+
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} not supported by GS1-8 Prefix"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=locale-strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-strings.js","sourceRoot":"","sources":["../../../src/locale/en/locale-strings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,KAAK,EAAE;QACH,2CAA2C,EAAE,qFAAqF;QAClI,sBAAsB,EAAE,iBAAiB;QACzC,0DAA0D,EAAE,sGAAsG;KACrK;IACD,iBAAiB,EAAE;QACf,2BAA2B,EAAE,0DAA0D;QACvF,iBAAiB,EAAE,qBAAqB;QACxC,iBAAiB,EAAE,2CAA2C;QAC9D,mBAAmB,EAAE,6BAA6B;QAClD,2BAA2B,EAAE,iCAAiC;QAC9D,6BAA6B,EAAE,+BAA+B;QAC9D,mCAAmC,EAAE,4CAA4C;QACjF,mCAAmC,EAAE,4CAA4C;QACjF,qBAAqB,EAAE,mEAAmE;QAC1F,mBAAmB,EAAE,wDAAwD;QAC7E,4BAA4B,EAAE,mEAAmE;QACjG,cAAc,EAAE,iBAAiB;QACjC,eAAe,EAAE,kBAAkB;QACnC,SAAS,EAAE,WAAW;QACtB,yBAAyB,EAAE,gCAAgC;QAC3D,yBAAyB,EAAE,8BAA8B;KAC5D;IACD,MAAM,EAAE;QACJ,gBAAgB,EAAE,oBAAoB;QACtC,gBAAgB,EAAE,uBAAuB;QACzC,UAAU,EAAE,cAAc;QAC1B,iBAAiB,EAAE,qBAAqB;QACxC,8BAA8B,EAAE,2CAA2C;QAC3E,kCAAkC,EAAE,+CAA+C;QACnF,mCAAmC,EAAE,gDAAgD;QACrF,iCAAiC,EAAE,iDAAiD;QACpF,wBAAwB,EAAE,qCAAqC;QAC/D,6CAA6C,EAAE,yDAAyD;KAC3G;CACK,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const localeStrings = {
|
|
2
|
+
Check: {
|
|
3
|
+
lengthOfStringForPriceOrWeightMustBeExactly: "La longueur {{longueur}} de la chaîne pour le prix ou la somme du poids doit être exactement {{exactLength}}",
|
|
4
|
+
priceOrWeightComponent: "prix ou poids",
|
|
5
|
+
lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: "La longueur {{length}} de la chaîne pour la paire de caractères de vérification doit être inférieure ou égale à {{maximum Length}}"
|
|
6
|
+
},
|
|
7
|
+
IdentificationKey: {
|
|
8
|
+
identificationKeyTypeLength: "{{identificationKeyType}} doit comporter {{length}} chiffres",
|
|
9
|
+
invalidCheckDigit: "Chiffre de contrôle non valide",
|
|
10
|
+
invalidGTINLength: "Le GTIN doit comporter 13, 12, 8 ou 14 chiffres",
|
|
11
|
+
invalidGTIN14Length: "Le GTIN doit comporter 14 chiffres",
|
|
12
|
+
invalidZeroSuppressedGTIN12: "Code GTIN-12 non valide avec zéro supprimé",
|
|
13
|
+
invalidZeroSuppressibleGTIN12: "Le GTIN-12 ne peut pas être supprimé par zéro",
|
|
14
|
+
invalidZeroSuppressedGTIN12AsGTIN13: "GTIN-12 non valide avec zéro supprimé en tant que GTIN-13",
|
|
15
|
+
invalidZeroSuppressedGTIN12AsGTIN14: "GTIN-12 non valide avec zéro supprimé en tant que GTIN-14",
|
|
16
|
+
invalidGTIN13AtRetail: "Le GTIN-13 au niveau des articles de consommation au détail ne peut pas commencer par zéro",
|
|
17
|
+
invalidGTINAtRetail: "Le GTIN n'est pas pris en charge au niveau des articles de consommation au détail",
|
|
18
|
+
invalidGTINAtOtherThanRetail: "Le GTIN n'est pas pris en charge à d'autres niveaux que ceux des articles de consommation au détail",
|
|
19
|
+
indicatorDigit: "chiffre indicateur",
|
|
20
|
+
serialComponent: "composant série",
|
|
21
|
+
reference: "référence",
|
|
22
|
+
referenceCantBeAllNumeric: "La référence ne peut pas être entièrement numérique",
|
|
23
|
+
invalidCheckCharacterPair: "Paire de caractères de contrôle non valide"
|
|
24
|
+
},
|
|
25
|
+
Prefix: {
|
|
26
|
+
gs1CompanyPrefix: "Préfixe de l'entreprise GS1",
|
|
27
|
+
upcCompanyPrefix: "Préfixe de l'entreprise U.P.C.",
|
|
28
|
+
gs18Prefix: "Préfixe GS1-8",
|
|
29
|
+
invalidPrefixType: "Type de préfixe invalide",
|
|
30
|
+
gs1CompanyPrefixCantStartWith0: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"0\"",
|
|
31
|
+
gs1CompanyPrefixCantStartWith00000: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"00000\"",
|
|
32
|
+
gs1CompanyPrefixCantStartWith000000: "Le préfixe de l'entreprise GS1 ne peut pas commencer par \"000000\"",
|
|
33
|
+
upcCompanyPrefixCantStartWith0000: "Le préfixe de l'entreprise U.P.C. ne peut pas commencer par \"0000\"",
|
|
34
|
+
gs18PrefixCantStartWith0: "Le préfixe GS1-8 ne peut pas commencer par \"0\"",
|
|
35
|
+
identificationKeyTypeNotSupportedByGS18Prefix: "{{identificationKeyType}} non pris en charge par le préfixe GS1-8"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=locale-strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-strings.js","sourceRoot":"","sources":["../../../src/locale/fr/locale-strings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,KAAK,EAAE;QACH,2CAA2C,EAAE,8GAA8G;QAC3J,sBAAsB,EAAE,eAAe;QACvC,0DAA0D,EAAE,oIAAoI;KACnM;IACD,iBAAiB,EAAE;QACf,2BAA2B,EAAE,8DAA8D;QAC3F,iBAAiB,EAAE,gCAAgC;QACnD,iBAAiB,EAAE,iDAAiD;QACpE,mBAAmB,EAAE,oCAAoC;QACzD,2BAA2B,EAAE,4CAA4C;QACzE,6BAA6B,EAAE,+CAA+C;QAC9E,mCAAmC,EAAE,2DAA2D;QAChG,mCAAmC,EAAE,2DAA2D;QAChG,qBAAqB,EAAE,4FAA4F;QACnH,mBAAmB,EAAE,mFAAmF;QACxG,4BAA4B,EAAE,qGAAqG;QACnI,cAAc,EAAE,oBAAoB;QACpC,eAAe,EAAE,iBAAiB;QAClC,SAAS,EAAE,WAAW;QACtB,yBAAyB,EAAE,qDAAqD;QAChF,yBAAyB,EAAE,4CAA4C;KAC1E;IACD,MAAM,EAAE;QACJ,gBAAgB,EAAE,6BAA6B;QAC/C,gBAAgB,EAAE,gCAAgC;QAClD,UAAU,EAAE,eAAe;QAC3B,iBAAiB,EAAE,0BAA0B;QAC7C,8BAA8B,EAAE,gEAAgE;QAChG,kCAAkC,EAAE,oEAAoE;QACxG,mCAAmC,EAAE,qEAAqE;QAC1G,iCAAiC,EAAE,sEAAsE;QACzG,wBAAwB,EAAE,kDAAkD;QAC5E,6CAA6C,EAAE,mEAAmE;KACrH;CACK,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { i18nAssertValidResources, i18nCoreInit } from "@aidc-toolkit/core";
|
|
2
|
+
import { i18nUtilityInit, utilityResources } from "@aidc-toolkit/utility";
|
|
3
|
+
import i18next from "i18next";
|
|
4
|
+
import { localeStrings as enLocaleStrings } from "./en/locale-strings.js";
|
|
5
|
+
import { localeStrings as frLocaleStrings } from "./fr/locale-strings.js";
|
|
6
|
+
export const gs1NS = "aidct_gs1";
|
|
7
|
+
i18nAssertValidResources(enLocaleStrings, "fr", frLocaleStrings);
|
|
8
|
+
/**
|
|
9
|
+
* GS1 resources.
|
|
10
|
+
*/
|
|
11
|
+
export const gs1Resources = {
|
|
12
|
+
en: {
|
|
13
|
+
aidct_gs1: enLocaleStrings
|
|
14
|
+
},
|
|
15
|
+
fr: {
|
|
16
|
+
aidct_gs1: frLocaleStrings
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// Explicit type is necessary to work around bug in type discovery with linked packages.
|
|
20
|
+
export const i18nextGS1 = i18next.createInstance();
|
|
21
|
+
/**
|
|
22
|
+
* Initialize internationalization.
|
|
23
|
+
*
|
|
24
|
+
* @param environment
|
|
25
|
+
* Environment in which the application is running.
|
|
26
|
+
*
|
|
27
|
+
* @param debug
|
|
28
|
+
* Debug setting.
|
|
29
|
+
*
|
|
30
|
+
* @returns
|
|
31
|
+
* Void promise.
|
|
32
|
+
*/
|
|
33
|
+
export async function i18nGS1Init(environment, debug = false) {
|
|
34
|
+
await i18nUtilityInit(environment, debug);
|
|
35
|
+
await i18nCoreInit(i18nextGS1, environment, debug, gs1NS, utilityResources, gs1Resources);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,OAAsB,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE1E,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;AAOjC,wBAAwB,CAAC,eAAe,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,EAAE,EAAE;QACA,SAAS,EAAE,eAAe;KAC7B;IACD,EAAE,EAAE;QACA,SAAS,EAAE,eAAe;KAC7B;CACJ,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,UAAU,GAAS,OAAO,CAAC,cAAc,EAAE,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAA4B,EAAE,KAAK,GAAG,KAAK;IACzE,MAAM,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC1C,MAAM,YAAY,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC9F,CAAC"}
|
package/gs1.iml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/gs1",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.17-beta",
|
|
4
4
|
"description": "GS1 AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,22 +19,20 @@
|
|
|
19
19
|
"url": "https://www.linkedin.com/in/kdean"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"update-aidc-toolkit": "npm update @aidc-toolkit/dev @aidc-toolkit/core @aidc-toolkit/utility",
|
|
23
22
|
"lint": "eslint",
|
|
24
|
-
"build:core": "
|
|
25
|
-
"build:dev": "npm run build:core
|
|
26
|
-
"build:release": "npm run build:core --
|
|
23
|
+
"build:core": "rimraf dist && tsc --project",
|
|
24
|
+
"build:dev": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build-dev.json",
|
|
25
|
+
"build:release": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build.json",
|
|
27
26
|
"build:doc": "npm run build:dev",
|
|
28
|
-
"publish-dev": "publish-dev",
|
|
29
27
|
"test": "vitest run"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
|
-
"@aidc-toolkit/dev": "^0.9.
|
|
33
|
-
"vitest": "^3.0.
|
|
30
|
+
"@aidc-toolkit/dev": "^0.9.17-beta",
|
|
31
|
+
"vitest": "^3.0.7"
|
|
34
32
|
},
|
|
35
33
|
"dependencies": {
|
|
36
|
-
"@aidc-toolkit/core": "^0.9.
|
|
37
|
-
"@aidc-toolkit/utility": "^0.9.
|
|
34
|
+
"@aidc-toolkit/core": "^0.9.17-beta",
|
|
35
|
+
"@aidc-toolkit/utility": "^0.9.17-beta",
|
|
38
36
|
"i18next": "^24.2.2",
|
|
39
37
|
"ts-mixer": "^6.0.4"
|
|
40
38
|
}
|
package/test/check.test.ts
CHANGED
package/test/idkey.test.ts
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
type SerializableNumericIdentificationKeyCreator,
|
|
41
41
|
type SerializableNumericIdentificationKeyValidator,
|
|
42
42
|
SSCC_VALIDATOR
|
|
43
|
-
} from "../src
|
|
43
|
+
} from "../src";
|
|
44
44
|
|
|
45
45
|
await i18nGS1Init(I18NEnvironment.CLI);
|
|
46
46
|
|
|
@@ -427,20 +427,20 @@ function testNumericIdentificationKeyCreator(creator: NumericIdentificationKeyCr
|
|
|
427
427
|
expect(creator.referenceLength).toBe(referenceLength);
|
|
428
428
|
expect(creator.capacity).toBe(Number(CharacterSetCreator.powerOf10(referenceLength)));
|
|
429
429
|
|
|
430
|
-
const sequenceIterator =
|
|
430
|
+
const sequenceIterator = creator.create(new Sequence(0, referenceCount))[Symbol.iterator]();
|
|
431
431
|
|
|
432
|
-
let
|
|
432
|
+
let index = 0;
|
|
433
433
|
|
|
434
|
-
|
|
434
|
+
for (const identificationKey of creator.createAll()) {
|
|
435
435
|
validate(identificationKey, index, false);
|
|
436
436
|
|
|
437
437
|
expect(Number((hasExtensionDigit ? identificationKey.charAt(0) : "") + identificationKey.substring(referenceSubstringStart, referenceSubstringEnd))).toBe(index);
|
|
438
438
|
expect(sequenceIterator.next().value).toBe(identificationKey);
|
|
439
439
|
|
|
440
|
-
|
|
441
|
-
}
|
|
440
|
+
index++;
|
|
441
|
+
}
|
|
442
442
|
|
|
443
|
-
expect(
|
|
443
|
+
expect(index).toBe(referenceCount);
|
|
444
444
|
expect(sequenceIterator.next().value).toBeUndefined();
|
|
445
445
|
|
|
446
446
|
const randomValues = new Array<number>();
|
|
@@ -464,9 +464,9 @@ function testNumericIdentificationKeyCreator(creator: NumericIdentificationKeyCr
|
|
|
464
464
|
|
|
465
465
|
const sequenceSet = new Set<string>();
|
|
466
466
|
|
|
467
|
-
let
|
|
467
|
+
let index = 0;
|
|
468
468
|
|
|
469
|
-
|
|
469
|
+
for (const identificationKey of creator.create(new Sequence(0, sparseReferenceCount), true)) {
|
|
470
470
|
validate(identificationKey, index, true);
|
|
471
471
|
|
|
472
472
|
sequential &&= Number((hasExtensionDigit ? identificationKey.charAt(0) : "") + identificationKey.substring(referenceSubstringStart, referenceSubstringEnd)) === index;
|
|
@@ -474,11 +474,11 @@ function testNumericIdentificationKeyCreator(creator: NumericIdentificationKeyCr
|
|
|
474
474
|
expect(sequenceSet.has(identificationKey)).toBe(false);
|
|
475
475
|
sequenceSet.add(identificationKey);
|
|
476
476
|
|
|
477
|
-
|
|
478
|
-
}
|
|
477
|
+
index++;
|
|
478
|
+
}
|
|
479
479
|
|
|
480
480
|
expect(sequential).toBe(false);
|
|
481
|
-
expect(
|
|
481
|
+
expect(index).toBe(sparseReferenceCount);
|
|
482
482
|
|
|
483
483
|
const randomValues = new Array<number>();
|
|
484
484
|
const identificationKeys = new Array<string>();
|
|
@@ -565,17 +565,17 @@ function testGTINCreator(creator: GTINCreator): void {
|
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
test("GTIN-14 straight", () => {
|
|
568
|
-
let
|
|
568
|
+
let index = 0;
|
|
569
569
|
|
|
570
|
-
|
|
570
|
+
for (const gtin of creator.createGTIN14("5", new Sequence(0, referenceCount))) {
|
|
571
571
|
expect(Number(gtin.substring(referenceSubstringStart, referenceSubstringEnd))).toBe(index);
|
|
572
572
|
|
|
573
573
|
validate(gtin, index, false);
|
|
574
574
|
|
|
575
|
-
|
|
576
|
-
}
|
|
575
|
+
index++;
|
|
576
|
+
}
|
|
577
577
|
|
|
578
|
-
expect(
|
|
578
|
+
expect(index).toBe(referenceCount);
|
|
579
579
|
|
|
580
580
|
const randomValues = new Array<number>();
|
|
581
581
|
const identificationKeys = new Array<string>();
|
|
@@ -598,9 +598,9 @@ function testGTINCreator(creator: GTINCreator): void {
|
|
|
598
598
|
|
|
599
599
|
const sequenceSet = new Set<string>();
|
|
600
600
|
|
|
601
|
-
let
|
|
601
|
+
let index = 0;
|
|
602
602
|
|
|
603
|
-
|
|
603
|
+
for (const gtin of creator.createGTIN14("5", new Sequence(0, sparseReferenceCount), true)) {
|
|
604
604
|
sequential &&= Number(gtin.substring(referenceSubstringStart, referenceSubstringEnd)) === index;
|
|
605
605
|
|
|
606
606
|
validate(gtin, index, true);
|
|
@@ -608,11 +608,11 @@ function testGTINCreator(creator: GTINCreator): void {
|
|
|
608
608
|
expect(sequenceSet.has(gtin)).toBe(false);
|
|
609
609
|
sequenceSet.add(gtin);
|
|
610
610
|
|
|
611
|
-
|
|
612
|
-
}
|
|
611
|
+
index++;
|
|
612
|
+
}
|
|
613
613
|
|
|
614
614
|
expect(sequential).toBe(false);
|
|
615
|
-
expect(
|
|
615
|
+
expect(index).toBe(sparseReferenceCount);
|
|
616
616
|
|
|
617
617
|
const randomValues = new Array<number>();
|
|
618
618
|
const identificationKeys = new Array<string>();
|
|
@@ -943,9 +943,9 @@ function testNonNumericIdentificationKeyCreator(creator: NonNumericIdentificatio
|
|
|
943
943
|
test("Straight", () => {
|
|
944
944
|
expect(creator.referenceLength).toBe(referenceLength);
|
|
945
945
|
|
|
946
|
-
let
|
|
946
|
+
let index = 0;
|
|
947
947
|
|
|
948
|
-
|
|
948
|
+
for (const identificationKey of creator.create(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, new Sequence(0, referenceCount)))) {
|
|
949
949
|
expect(() => {
|
|
950
950
|
creator.validate(identificationKey);
|
|
951
951
|
}).not.toThrow(RangeError);
|
|
@@ -958,18 +958,18 @@ function testNonNumericIdentificationKeyCreator(creator: NonNumericIdentificatio
|
|
|
958
958
|
|
|
959
959
|
expect(identificationKey).toBe(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, index, Exclusion.None, undefined, reference => creator.create(reference)));
|
|
960
960
|
|
|
961
|
-
|
|
962
|
-
}
|
|
961
|
+
index++;
|
|
962
|
+
}
|
|
963
963
|
|
|
964
|
-
expect(
|
|
964
|
+
expect(index).toBe(referenceCount);
|
|
965
965
|
});
|
|
966
966
|
|
|
967
967
|
test("Sparse", () => {
|
|
968
968
|
let sequential = true;
|
|
969
969
|
|
|
970
|
-
let
|
|
970
|
+
let index = 0;
|
|
971
971
|
|
|
972
|
-
|
|
972
|
+
for (const identificationKey of creator.create(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, new Sequence(0, referenceCount), Exclusion.None, 123456n))) {
|
|
973
973
|
expect(() => {
|
|
974
974
|
creator.validate(identificationKey);
|
|
975
975
|
}).not.toThrow(RangeError);
|
|
@@ -984,11 +984,11 @@ function testNonNumericIdentificationKeyCreator(creator: NonNumericIdentificatio
|
|
|
984
984
|
|
|
985
985
|
expect(identificationKey).toBe(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, index, Exclusion.None, 123456n, reference => creator.create(reference)));
|
|
986
986
|
|
|
987
|
-
|
|
988
|
-
}
|
|
987
|
+
index++;
|
|
988
|
+
}
|
|
989
989
|
|
|
990
990
|
expect(sequential).toBe(false);
|
|
991
|
-
expect(
|
|
991
|
+
expect(index).toBe(referenceCount);
|
|
992
992
|
});
|
|
993
993
|
|
|
994
994
|
test("Position offset", () => {
|