@aidc-toolkit/utility 0.9.16-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/package.json +3 -5
- package/test/character-set.test.ts +25 -16
- package/test/record.test.ts +1 -1
- package/test/reg-exp.test.ts +1 -1
- package/test/sequence.test.ts +3 -3
- package/test/transformer.test.ts +9 -7
- package/typedoc.json +1 -3
- package/utility.iml +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/utility",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.17-beta",
|
|
4
4
|
"description": "Foundational utilities for AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,21 +19,19 @@
|
|
|
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",
|
|
23
22
|
"lint": "eslint",
|
|
24
23
|
"build:core": "rimraf dist && tsc --project",
|
|
25
24
|
"build:dev": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build-dev.json",
|
|
26
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.
|
|
30
|
+
"@aidc-toolkit/dev": "^0.9.17-beta",
|
|
33
31
|
"vitest": "^3.0.7"
|
|
34
32
|
},
|
|
35
33
|
"dependencies": {
|
|
36
|
-
"@aidc-toolkit/core": "^0.9.
|
|
34
|
+
"@aidc-toolkit/core": "^0.9.17-beta",
|
|
37
35
|
"i18next": "^24.2.2"
|
|
38
36
|
}
|
|
39
37
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
i18nUtilityInit,
|
|
10
10
|
NUMERIC_CREATOR,
|
|
11
11
|
Sequence
|
|
12
|
-
} from "../src
|
|
12
|
+
} from "../src";
|
|
13
13
|
|
|
14
14
|
await i18nUtilityInit(I18NEnvironment.CLI);
|
|
15
15
|
|
|
@@ -65,13 +65,13 @@ function testCharacterSetCreator(name: string, characterSetCreator: CharacterSet
|
|
|
65
65
|
break;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const sequence =
|
|
68
|
+
const sequence = characterSetCreator.create(length, new Sequence(0n, domain), exclusion);
|
|
69
69
|
|
|
70
70
|
let previousS = "";
|
|
71
71
|
|
|
72
|
-
let
|
|
72
|
+
let index = 0;
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
for (const s of sequence) {
|
|
75
75
|
expect(s > previousS).toBe(true);
|
|
76
76
|
previousS = s;
|
|
77
77
|
|
|
@@ -79,23 +79,23 @@ function testCharacterSetCreator(name: string, characterSetCreator: CharacterSet
|
|
|
79
79
|
|
|
80
80
|
expect(characterSetCreator.valueFor(s, exclusion)).toBe(BigInt(index));
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
}
|
|
82
|
+
index++;
|
|
83
|
+
}
|
|
84
84
|
|
|
85
|
-
expect(
|
|
85
|
+
expect(index).toBe(domain);
|
|
86
86
|
|
|
87
87
|
expect(() => characterSetCreator.create(length, domain, exclusion)).toThrow(`Value ${domain} must be less than ${domain}`);
|
|
88
88
|
|
|
89
|
-
const sparseSequence =
|
|
89
|
+
const sparseSequence = characterSetCreator.create(length, new Sequence(domain - 1, -domain), exclusion, 123456n);
|
|
90
90
|
|
|
91
91
|
let sequential = true;
|
|
92
92
|
previousS = "~";
|
|
93
93
|
|
|
94
94
|
const sequenceSet = new Set<string>();
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
index = 0;
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
for (const s of sparseSequence) {
|
|
99
99
|
sequential &&= s < previousS;
|
|
100
100
|
previousS = s;
|
|
101
101
|
|
|
@@ -106,11 +106,11 @@ function testCharacterSetCreator(name: string, characterSetCreator: CharacterSet
|
|
|
106
106
|
|
|
107
107
|
expect(characterSetCreator.valueFor(s, exclusion, 123456n)).toBe(BigInt(domain - index - 1));
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
}
|
|
109
|
+
index++;
|
|
110
|
+
}
|
|
111
111
|
|
|
112
112
|
expect(sequential).toBe(false);
|
|
113
|
-
expect(
|
|
113
|
+
expect(index).toBe(domain);
|
|
114
114
|
|
|
115
115
|
const randomValues = new Array<bigint>();
|
|
116
116
|
const straightRandomValues = new Array<string>();
|
|
@@ -137,12 +137,18 @@ function testCharacterSetCreator(name: string, characterSetCreator: CharacterSet
|
|
|
137
137
|
expect(() => characterSetCreator.create(41, 0)).toThrow("Length 41 must be less than or equal to 40");
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
test("Create sequence",
|
|
140
|
+
test("Create sequence", {
|
|
141
|
+
// Test can take a moderate amount of time.
|
|
142
|
+
timeout: 10 * 1000
|
|
143
|
+
}, () => {
|
|
141
144
|
testCreate(Exclusion.None);
|
|
142
145
|
});
|
|
143
146
|
|
|
144
147
|
if (excludeFirstZero) {
|
|
145
|
-
test("Create sequence, exclude first zero",
|
|
148
|
+
test("Create sequence, exclude first zero", {
|
|
149
|
+
// Test can take a moderate amount of time.
|
|
150
|
+
timeout: 10 * 1000
|
|
151
|
+
}, () => {
|
|
146
152
|
testCreate(Exclusion.FirstZero);
|
|
147
153
|
|
|
148
154
|
expect(() => characterSetCreator.valueFor("0000", Exclusion.FirstZero)).toThrow("Invalid character '0' at position 1");
|
|
@@ -151,7 +157,10 @@ function testCharacterSetCreator(name: string, characterSetCreator: CharacterSet
|
|
|
151
157
|
}
|
|
152
158
|
|
|
153
159
|
if (excludeAllNumeric) {
|
|
154
|
-
test("Create sequence, exclude all numeric",
|
|
160
|
+
test("Create sequence, exclude all numeric", {
|
|
161
|
+
// Test can take a moderate amount of time.
|
|
162
|
+
timeout: 10 * 1000
|
|
163
|
+
}, () => {
|
|
155
164
|
testCreate(Exclusion.AllNumeric);
|
|
156
165
|
|
|
157
166
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Nine is known to be present in the character set.
|
package/test/record.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I18NEnvironment } from "@aidc-toolkit/core";
|
|
2
2
|
import { describe, expect, test } from "vitest";
|
|
3
|
-
import { i18nUtilityInit, RecordValidator } from "../src
|
|
3
|
+
import { i18nUtilityInit, RecordValidator } from "../src";
|
|
4
4
|
|
|
5
5
|
await i18nUtilityInit(I18NEnvironment.CLI);
|
|
6
6
|
|
package/test/reg-exp.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I18NEnvironment } from "@aidc-toolkit/core";
|
|
2
2
|
import { describe, expect, test } from "vitest";
|
|
3
|
-
import { i18nUtilityInit, RegExpValidator } from "../src
|
|
3
|
+
import { i18nUtilityInit, RegExpValidator } from "../src";
|
|
4
4
|
|
|
5
5
|
await i18nUtilityInit(I18NEnvironment.CLI);
|
|
6
6
|
|
package/test/sequence.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I18NEnvironment } from "@aidc-toolkit/core";
|
|
2
2
|
import { describe, expect, test } from "vitest";
|
|
3
|
-
import { i18nUtilityInit, Sequence } from "../src
|
|
3
|
+
import { i18nUtilityInit, Sequence } from "../src";
|
|
4
4
|
|
|
5
5
|
await i18nUtilityInit(I18NEnvironment.CLI);
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ describe("Sequence", () => {
|
|
|
29
29
|
expectedValue = 10n;
|
|
30
30
|
count = 0;
|
|
31
31
|
|
|
32
|
-
for (const value of
|
|
32
|
+
for (const value of sequence1) {
|
|
33
33
|
expect(value).toBe(expectedValue);
|
|
34
34
|
|
|
35
35
|
expectedValue++;
|
|
@@ -41,7 +41,7 @@ describe("Sequence", () => {
|
|
|
41
41
|
expectedValue = 29n;
|
|
42
42
|
count = 0;
|
|
43
43
|
|
|
44
|
-
for (const value of
|
|
44
|
+
for (const value of sequence2) {
|
|
45
45
|
expect(value).toBe(expectedValue);
|
|
46
46
|
|
|
47
47
|
expectedValue--;
|
package/test/transformer.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I18NEnvironment } from "@aidc-toolkit/core";
|
|
2
2
|
import { describe, expect, test } from "vitest";
|
|
3
|
-
import { EncryptionTransformer, i18nUtilityInit, IdentityTransformer, Sequence, Transformer } from "../src
|
|
3
|
+
import { EncryptionTransformer, i18nUtilityInit, IdentityTransformer, Sequence, Transformer } from "../src";
|
|
4
4
|
|
|
5
5
|
await i18nUtilityInit(I18NEnvironment.CLI);
|
|
6
6
|
|
|
@@ -11,22 +11,24 @@ function testTransformer(domain: number, tweak?: number, callback?: (value: bigi
|
|
|
11
11
|
|
|
12
12
|
const transformedValuesSet = new Set<bigint>();
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
const indexN = BigInt(index);
|
|
14
|
+
let index = 0n;
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
for (const transformedValue of transformer.forward(new Sequence(0n, domain))) {
|
|
17
|
+
if (sequential && transformedValue !== index) {
|
|
18
18
|
sequential = false;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
expect(transformedValuesSet.has(transformedValue)).toBe(false);
|
|
22
|
-
expect(transformer.reverse(transformedValue)).toBe(
|
|
22
|
+
expect(transformer.reverse(transformedValue)).toBe(index);
|
|
23
23
|
|
|
24
24
|
transformedValuesSet.add(transformedValue);
|
|
25
25
|
|
|
26
26
|
if (callback !== undefined) {
|
|
27
|
-
callback(
|
|
27
|
+
callback(index, transformedValue);
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
index++;
|
|
31
|
+
}
|
|
30
32
|
|
|
31
33
|
expect(sequential).toBe(tweak === undefined);
|
|
32
34
|
|
package/typedoc.json
CHANGED
package/utility.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>
|