@aidc-toolkit/utility 0.9.8-beta → 0.9.9-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/LICENSE +0 -27
- package/README.md +14 -0
- package/dist/index.cjs +95 -74
- package/dist/index.d.cts +71 -550
- package/dist/index.d.ts +71 -550
- package/dist/index.js +91 -70
- package/package.json +8 -8
- package/src/character-set.ts +1 -1
- package/src/index.ts +17 -1
- package/src/locale/en/locale-strings.ts +2 -2
- package/src/locale/fr/locale-strings.ts +2 -2
- package/src/locale/i18n.ts +3 -2
- package/src/{sequencer.ts → sequence.ts} +12 -12
- package/src/transformer.ts +102 -99
- package/test/character-set.test.ts +4 -4
- package/test/{sequencer.test.ts → sequence.test.ts} +16 -16
- package/test/transformer.test.ts +20 -21
package/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ var localeStrings = {
|
|
|
9
9
|
tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak}} must be greater than or equal to 0",
|
|
10
10
|
valueMustBeGreaterThanOrEqualToZero: "Value {{value}} must be greater than or equal to 0",
|
|
11
11
|
valueMustBeLessThan: "Value {{value}} must be less than {{domain}}",
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
minimumValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minimumValue}} must be greater than or equal to 0",
|
|
13
|
+
maximumValueMustBeLessThan: "Maximum value {{maximumValue}} must be less than {{domain}}"
|
|
14
14
|
},
|
|
15
15
|
RegExpValidator: {
|
|
16
16
|
stringDoesNotMatchPattern: "String {{s}} does not match pattern"
|
|
@@ -43,8 +43,8 @@ var localeStrings2 = {
|
|
|
43
43
|
tweakMustBeGreaterThanOrEqualToZero: "Le r\xE9glage {{tweak}} doit \xEAtre sup\xE9rieur ou \xE9gal \xE0 0",
|
|
44
44
|
valueMustBeGreaterThanOrEqualToZero: "La valeur {{value}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",
|
|
45
45
|
valueMustBeLessThan: "La valeur {{value}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}",
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
minimumValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minimumValue}} doit \xEAtre sup\xE9rieure ou \xE9gale \xE0 0",
|
|
47
|
+
maximumValueMustBeLessThan: "La valeur maximale {{maximumValue}} doit \xEAtre inf\xE9rieure \xE0 {{domain}}"
|
|
48
48
|
},
|
|
49
49
|
RegExpValidator: {
|
|
50
50
|
stringDoesNotMatchPattern: "La cha\xEEne {{s}} ne correspond pas au mod\xE8le"
|
|
@@ -86,8 +86,8 @@ async function i18nUtilityInit(environment, debug = false) {
|
|
|
86
86
|
await i18nCoreInit(i18nextUtility, environment, debug, utilityNS, utilityResources);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
// src/
|
|
90
|
-
var
|
|
89
|
+
// src/sequence.ts
|
|
90
|
+
var Sequence = class {
|
|
91
91
|
/**
|
|
92
92
|
* Start value (inclusive).
|
|
93
93
|
*/
|
|
@@ -107,11 +107,11 @@ var Sequencer = class {
|
|
|
107
107
|
/**
|
|
108
108
|
* Minimum value (inclusive).
|
|
109
109
|
*/
|
|
110
|
-
|
|
110
|
+
_minimumValue;
|
|
111
111
|
/**
|
|
112
112
|
* Maximum value (inclusive).
|
|
113
113
|
*/
|
|
114
|
-
|
|
114
|
+
_maximumValue;
|
|
115
115
|
/**
|
|
116
116
|
* Constructor.
|
|
117
117
|
*
|
|
@@ -128,12 +128,12 @@ var Sequencer = class {
|
|
|
128
128
|
this._count = count;
|
|
129
129
|
if (count >= 0) {
|
|
130
130
|
this._nextDelta = 1n;
|
|
131
|
-
this.
|
|
132
|
-
this.
|
|
131
|
+
this._minimumValue = this._startValue;
|
|
132
|
+
this._maximumValue = this._endValue - 1n;
|
|
133
133
|
} else {
|
|
134
134
|
this._nextDelta = -1n;
|
|
135
|
-
this.
|
|
136
|
-
this.
|
|
135
|
+
this._minimumValue = this._endValue + 1n;
|
|
136
|
+
this._maximumValue = this._startValue;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
@@ -157,14 +157,14 @@ var Sequencer = class {
|
|
|
157
157
|
/**
|
|
158
158
|
* Get the minimum value (inclusive).
|
|
159
159
|
*/
|
|
160
|
-
get
|
|
161
|
-
return this.
|
|
160
|
+
get minimumValue() {
|
|
161
|
+
return this._minimumValue;
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
164
|
* Get the maximum value (inclusive).
|
|
165
165
|
*/
|
|
166
|
-
get
|
|
167
|
-
return this.
|
|
166
|
+
get maximumValue() {
|
|
167
|
+
return this._maximumValue;
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Iterable implementation.
|
|
@@ -180,12 +180,18 @@ var Sequencer = class {
|
|
|
180
180
|
};
|
|
181
181
|
|
|
182
182
|
// src/transformer.ts
|
|
183
|
-
function transformIterable(
|
|
183
|
+
function transformIterable(values, transformerCallback) {
|
|
184
184
|
return {
|
|
185
|
+
/**
|
|
186
|
+
* Iterable implementation.
|
|
187
|
+
*
|
|
188
|
+
* @yields
|
|
189
|
+
* Next output value.
|
|
190
|
+
*/
|
|
185
191
|
*[Symbol.iterator]() {
|
|
186
192
|
let index = 0;
|
|
187
|
-
for (const
|
|
188
|
-
yield transformerCallback(
|
|
193
|
+
for (const value of values) {
|
|
194
|
+
yield transformerCallback(value, index++);
|
|
189
195
|
}
|
|
190
196
|
}
|
|
191
197
|
};
|
|
@@ -268,45 +274,58 @@ var Transformer = class _Transformer {
|
|
|
268
274
|
}));
|
|
269
275
|
}
|
|
270
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Validate that a value is within the domain and do the work of transforming it forward.
|
|
279
|
+
*
|
|
280
|
+
* @param value
|
|
281
|
+
* Value.
|
|
282
|
+
*
|
|
283
|
+
* @returns
|
|
284
|
+
* Transformed value.
|
|
285
|
+
*/
|
|
286
|
+
validateDoForward(value) {
|
|
287
|
+
const valueN = BigInt(value);
|
|
288
|
+
this.validate(valueN);
|
|
289
|
+
return this.doForward(valueN);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Validate that a value is within the domain, do the work of transforming it forward, and apply a callback.
|
|
293
|
+
*
|
|
294
|
+
* @param transformerCallback
|
|
295
|
+
* Called after each value is transformed to convert it to its final value.
|
|
296
|
+
*
|
|
297
|
+
* @param value
|
|
298
|
+
* Value.
|
|
299
|
+
*
|
|
300
|
+
* @param index
|
|
301
|
+
* Index in sequence (0 for single transformation).
|
|
302
|
+
*
|
|
303
|
+
* @returns
|
|
304
|
+
* Transformed value.
|
|
305
|
+
*/
|
|
306
|
+
validateDoForwardCallback(transformerCallback, value, index) {
|
|
307
|
+
return transformerCallback(this.validateDoForward(value), index);
|
|
308
|
+
}
|
|
271
309
|
// eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
|
|
272
310
|
forward(valueOrValues, transformerCallback) {
|
|
273
311
|
let result;
|
|
274
312
|
if (typeof valueOrValues !== "object") {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
if (valueOrValues.minValue < 0n) {
|
|
281
|
-
throw new RangeError(i18nextUtility.t("Transformer.minValueMustBeGreaterThanOrEqualToZero", {
|
|
282
|
-
minValue: valueOrValues.minValue
|
|
313
|
+
result = transformerCallback === void 0 ? this.validateDoForward(valueOrValues) : this.validateDoForwardCallback(transformerCallback, valueOrValues, 0);
|
|
314
|
+
} else if (valueOrValues instanceof Sequence) {
|
|
315
|
+
if (valueOrValues.minimumValue < 0n) {
|
|
316
|
+
throw new RangeError(i18nextUtility.t("Transformer.minimumValueMustBeGreaterThanOrEqualToZero", {
|
|
317
|
+
minimumValue: valueOrValues.minimumValue
|
|
283
318
|
}));
|
|
284
319
|
}
|
|
285
|
-
if (valueOrValues.
|
|
286
|
-
throw new RangeError(i18nextUtility.t("Transformer.
|
|
287
|
-
|
|
320
|
+
if (valueOrValues.maximumValue >= this.domain) {
|
|
321
|
+
throw new RangeError(i18nextUtility.t("Transformer.maximumValueMustBeLessThan", {
|
|
322
|
+
maximumValue: valueOrValues.maximumValue,
|
|
288
323
|
domain: this.domain
|
|
289
324
|
}));
|
|
290
325
|
}
|
|
291
|
-
|
|
292
|
-
result = transformIterable(valueOrValues, (value) => this.doForward(value));
|
|
293
|
-
} else {
|
|
294
|
-
result = transformIterable(valueOrValues, (value, index) => transformerCallback(this.doForward(value), index));
|
|
295
|
-
}
|
|
326
|
+
result = transformerCallback === void 0 ? transformIterable(valueOrValues, (value) => this.doForward(value)) : transformIterable(valueOrValues, (value, index) => transformerCallback(this.doForward(value), index));
|
|
296
327
|
} else {
|
|
297
|
-
|
|
298
|
-
result = transformIterable(valueOrValues, (value) => {
|
|
299
|
-
const valueN = BigInt(value);
|
|
300
|
-
this.validate(valueN);
|
|
301
|
-
return this.doForward(valueN);
|
|
302
|
-
});
|
|
303
|
-
} else {
|
|
304
|
-
result = transformIterable(valueOrValues, (value, index) => {
|
|
305
|
-
const valueN = BigInt(value);
|
|
306
|
-
this.validate(valueN);
|
|
307
|
-
return transformerCallback(this.doForward(valueN), index);
|
|
308
|
-
});
|
|
309
|
-
}
|
|
328
|
+
result = transformerCallback === void 0 ? transformIterable(valueOrValues, (value) => this.validateDoForward(value)) : transformIterable(valueOrValues, (value, index) => this.validateDoForwardCallback(transformerCallback, value, index));
|
|
310
329
|
}
|
|
311
330
|
return result;
|
|
312
331
|
}
|
|
@@ -370,10 +389,6 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
|
|
|
370
389
|
* Number of bytes covered by the domain.
|
|
371
390
|
*/
|
|
372
391
|
_domainBytes;
|
|
373
|
-
/**
|
|
374
|
-
* Tweak.
|
|
375
|
-
*/
|
|
376
|
-
_tweak;
|
|
377
392
|
/**
|
|
378
393
|
* Xor bytes array generated from the domain and tweak.
|
|
379
394
|
*/
|
|
@@ -407,18 +422,16 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
|
|
|
407
422
|
}));
|
|
408
423
|
}
|
|
409
424
|
let domainBytes = 0;
|
|
410
|
-
for (let reducedDomainMinusOne = this.domain - 1n; reducedDomainMinusOne !== 0n; reducedDomainMinusOne
|
|
425
|
+
for (let reducedDomainMinusOne = this.domain - 1n; reducedDomainMinusOne !== 0n; reducedDomainMinusOne >>= 8n) {
|
|
411
426
|
domainBytes++;
|
|
412
427
|
}
|
|
413
428
|
this._domainBytes = domainBytes;
|
|
414
|
-
this._tweak = BigInt(tweak);
|
|
415
429
|
const xorBytes = new Array();
|
|
416
430
|
const bits = new Array();
|
|
417
431
|
const inverseBits = new Array();
|
|
418
|
-
for (let reducedKey = this.domain *
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
const bitNumber = keyByte & 7;
|
|
432
|
+
for (let reducedKey = this.domain * BigInt(tweak) * 603868999n; reducedKey !== 0n; reducedKey >>= 8n) {
|
|
433
|
+
xorBytes.unshift(Number(BigInt.asUintN(8, reducedKey)));
|
|
434
|
+
const bitNumber = Number(BigInt.asUintN(3, reducedKey));
|
|
422
435
|
bits.push(_EncryptionTransformer.BITS[bitNumber]);
|
|
423
436
|
inverseBits.push(_EncryptionTransformer.INVERSE_BITS[bitNumber]);
|
|
424
437
|
}
|
|
@@ -435,12 +448,6 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
|
|
|
435
448
|
this._rounds = xorBytes.length;
|
|
436
449
|
}
|
|
437
450
|
}
|
|
438
|
-
/**
|
|
439
|
-
* Get the tweak.
|
|
440
|
-
*/
|
|
441
|
-
get tweak() {
|
|
442
|
-
return this._tweak;
|
|
443
|
-
}
|
|
444
451
|
/**
|
|
445
452
|
* Convert a value to a byte array big enough to handle the entire domain.
|
|
446
453
|
*
|
|
@@ -452,10 +459,8 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
|
|
|
452
459
|
*/
|
|
453
460
|
valueToBytes(value) {
|
|
454
461
|
const bytes = new Uint8Array(this._domainBytes);
|
|
455
|
-
let reducedValue = value;
|
|
456
|
-
|
|
457
|
-
bytes[index] = Number(reducedValue & 0xFFn);
|
|
458
|
-
reducedValue = reducedValue >> 8n;
|
|
462
|
+
for (let index = this._domainBytes - 1, reducedValue = value; index >= 0 && reducedValue !== 0n; index--, reducedValue >>= 8n) {
|
|
463
|
+
bytes[index] = Number(BigInt.asUintN(8, reducedValue));
|
|
459
464
|
}
|
|
460
465
|
return bytes;
|
|
461
466
|
}
|
|
@@ -1111,7 +1116,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
1111
1116
|
}
|
|
1112
1117
|
s = this.character(exclusion === 1 /* FirstZero */ ? Number(convertValue % this._characterSetSizeMinusOneN) + 1 : Number(convertValue % this._characterSetSizeN)) + s;
|
|
1113
1118
|
}
|
|
1114
|
-
return creatorCallback
|
|
1119
|
+
return creatorCallback === void 0 ? s : creatorCallback(s, index);
|
|
1115
1120
|
});
|
|
1116
1121
|
}
|
|
1117
1122
|
/**
|
|
@@ -1273,7 +1278,7 @@ export {
|
|
|
1273
1278
|
NUMERIC_CREATOR,
|
|
1274
1279
|
RecordValidator,
|
|
1275
1280
|
RegExpValidator,
|
|
1276
|
-
|
|
1281
|
+
Sequence,
|
|
1277
1282
|
Transformer,
|
|
1278
1283
|
i18nUtilityInit,
|
|
1279
1284
|
i18nextUtility,
|
|
@@ -1281,3 +1286,19 @@ export {
|
|
|
1281
1286
|
utilityNS,
|
|
1282
1287
|
utilityResources
|
|
1283
1288
|
};
|
|
1289
|
+
/*!
|
|
1290
|
+
* Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
|
|
1291
|
+
* contributors
|
|
1292
|
+
*
|
|
1293
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1294
|
+
* you may not use this file except in compliance with the License.
|
|
1295
|
+
* You may obtain a copy of the License at
|
|
1296
|
+
*
|
|
1297
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
1298
|
+
*
|
|
1299
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1300
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1301
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1302
|
+
* See the License for the specific language governing permissions and
|
|
1303
|
+
* limitations under the License.
|
|
1304
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/utility",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9-beta",
|
|
4
4
|
"description": "Foundational utilities for AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,21 +20,21 @@
|
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"lint": "eslint .",
|
|
23
|
-
"build": "tsup src/index.ts --clean --format cjs,esm --dts",
|
|
24
|
-
"build-doc": "npm run build && tsc src/index.ts --outDir dist --target esnext --moduleResolution nodenext --module nodenext --emitDeclarationOnly --declaration --declarationMap",
|
|
23
|
+
"build-dist": "tsup src/index.ts --clean --format cjs,esm --dts",
|
|
24
|
+
"build-doc": "npm run build-dist && tsc src/index.ts --outDir dist --target esnext --moduleResolution nodenext --module nodenext --emitDeclarationOnly --declaration --declarationMap",
|
|
25
25
|
"test": "vitest run"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@aidc-toolkit/dev": "^0.9.
|
|
29
|
-
"eslint": "^9.
|
|
28
|
+
"@aidc-toolkit/dev": "^0.9.9-beta",
|
|
29
|
+
"eslint": "^9.17.0",
|
|
30
30
|
"ts-node": "^10.9.2",
|
|
31
31
|
"tsup": "^8.3.5",
|
|
32
32
|
"typescript": "^5.7.2",
|
|
33
33
|
"vitest": "^2.1.8"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@aidc-toolkit/core": "^0.9.
|
|
37
|
-
"@rollup/rollup-linux-x64-gnu": "^4.
|
|
38
|
-
"i18next": "^24.
|
|
36
|
+
"@aidc-toolkit/core": "^0.9.9-beta",
|
|
37
|
+
"@rollup/rollup-linux-x64-gnu": "^4.29.1",
|
|
38
|
+
"i18next": "^24.2.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/character-set.ts
CHANGED
|
@@ -585,7 +585,7 @@ export class CharacterSetCreator extends CharacterSetValidator {
|
|
|
585
585
|
s = this.character(exclusion === Exclusion.FirstZero ? Number(convertValue % this._characterSetSizeMinusOneN) + 1 : Number(convertValue % this._characterSetSizeN)) + s;
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
return creatorCallback
|
|
588
|
+
return creatorCallback === undefined ? s : creatorCallback(s, index);
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
591
|
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit
|
|
3
|
+
* contributors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
export * from "./locale/i18n.js";
|
|
2
|
-
export * from "./
|
|
18
|
+
export * from "./sequence.js";
|
|
3
19
|
export * from "./transformer.js";
|
|
4
20
|
export type * from "./string.js";
|
|
5
21
|
export * from "./reg-exp.js";
|
|
@@ -4,8 +4,8 @@ export const localeStrings = {
|
|
|
4
4
|
tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak}} must be greater than or equal to 0",
|
|
5
5
|
valueMustBeGreaterThanOrEqualToZero: "Value {{value}} must be greater than or equal to 0",
|
|
6
6
|
valueMustBeLessThan: "Value {{value}} must be less than {{domain}}",
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
minimumValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minimumValue}} must be greater than or equal to 0",
|
|
8
|
+
maximumValueMustBeLessThan: "Maximum value {{maximumValue}} must be less than {{domain}}"
|
|
9
9
|
},
|
|
10
10
|
RegExpValidator: {
|
|
11
11
|
stringDoesNotMatchPattern: "String {{s}} does not match pattern"
|
|
@@ -4,8 +4,8 @@ export const localeStrings = {
|
|
|
4
4
|
tweakMustBeGreaterThanOrEqualToZero: "Le réglage {{tweak}} doit être supérieur ou égal à 0",
|
|
5
5
|
valueMustBeGreaterThanOrEqualToZero: "La valeur {{value}} doit être supérieure ou égale à 0",
|
|
6
6
|
valueMustBeLessThan: "La valeur {{value}} doit être inférieure à {{domain}}",
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
minimumValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minimumValue}} doit être supérieure ou égale à 0",
|
|
8
|
+
maximumValueMustBeLessThan: "La valeur maximale {{maximumValue}} doit être inférieure à {{domain}}"
|
|
9
9
|
},
|
|
10
10
|
RegExpValidator: {
|
|
11
11
|
stringDoesNotMatchPattern: "La chaîne {{s}} ne correspond pas au modèle"
|
package/src/locale/i18n.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i18nAssertValidResources, i18nCoreInit, type I18NEnvironment } from "@aidc-toolkit/core";
|
|
2
|
-
import i18next, { type Resource } from "i18next";
|
|
2
|
+
import i18next, { type i18n, type Resource } from "i18next";
|
|
3
3
|
import { localeStrings as enLocaleStrings } from "./en/locale-strings.js";
|
|
4
4
|
import { localeStrings as frLocaleStrings } from "./fr/locale-strings.js";
|
|
5
5
|
|
|
@@ -24,7 +24,8 @@ export const utilityResources: Resource = {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// Explicit type is necessary to work around bug in type discovery with linked packages.
|
|
28
|
+
export const i18nextUtility: i18n = i18next.createInstance();
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Initialize internationalization.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Sequence. Defines an ascending or descending sequence of big integers implemented as an iterable.
|
|
3
3
|
*/
|
|
4
|
-
export class
|
|
4
|
+
export class Sequence implements Iterable<bigint> {
|
|
5
5
|
/**
|
|
6
6
|
* Start value (inclusive).
|
|
7
7
|
*/
|
|
@@ -25,12 +25,12 @@ export class Sequencer implements Iterable<bigint> {
|
|
|
25
25
|
/**
|
|
26
26
|
* Minimum value (inclusive).
|
|
27
27
|
*/
|
|
28
|
-
private readonly
|
|
28
|
+
private readonly _minimumValue: bigint;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Maximum value (inclusive).
|
|
32
32
|
*/
|
|
33
|
-
private readonly
|
|
33
|
+
private readonly _maximumValue: bigint;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Constructor.
|
|
@@ -49,12 +49,12 @@ export class Sequencer implements Iterable<bigint> {
|
|
|
49
49
|
|
|
50
50
|
if (count >= 0) {
|
|
51
51
|
this._nextDelta = 1n;
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
52
|
+
this._minimumValue = this._startValue;
|
|
53
|
+
this._maximumValue = this._endValue - 1n;
|
|
54
54
|
} else {
|
|
55
55
|
this._nextDelta = -1n;
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
56
|
+
this._minimumValue = this._endValue + 1n;
|
|
57
|
+
this._maximumValue = this._startValue;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -82,15 +82,15 @@ export class Sequencer implements Iterable<bigint> {
|
|
|
82
82
|
/**
|
|
83
83
|
* Get the minimum value (inclusive).
|
|
84
84
|
*/
|
|
85
|
-
get
|
|
86
|
-
return this.
|
|
85
|
+
get minimumValue(): bigint {
|
|
86
|
+
return this._minimumValue;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Get the maximum value (inclusive).
|
|
91
91
|
*/
|
|
92
|
-
get
|
|
93
|
-
return this.
|
|
92
|
+
get maximumValue(): bigint {
|
|
93
|
+
return this._maximumValue;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|