@aidc-toolkit/utility 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.
- package/README.md +30 -30
- package/dist/index.cjs +3569 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +947 -0
- package/dist/index.d.ts +947 -26
- package/dist/index.js +3504 -8
- package/dist/index.js.map +1 -1
- package/package.json +4 -8
- package/src/character-set.ts +6 -6
- package/src/index.ts +9 -9
- package/src/locale/en/{locale-strings.ts → locale-resources.ts} +1 -1
- package/src/locale/fr/{locale-strings.ts → locale-resources.ts} +1 -1
- package/src/locale/i18n.ts +6 -8
- package/src/locale/i18next.d.ts +2 -2
- package/src/record.ts +2 -2
- package/src/reg-exp.ts +2 -2
- package/src/transformer.ts +3 -3
- package/tsup.config.ts +3 -0
- package/typedoc.json +1 -3
- package/dist/character-set.d.ts +0 -307
- package/dist/character-set.d.ts.map +0 -1
- package/dist/character-set.js +0 -563
- package/dist/character-set.js.map +0 -1
- package/dist/exclusion.d.ts +0 -22
- package/dist/exclusion.d.ts.map +0 -1
- package/dist/exclusion.js +0 -18
- package/dist/exclusion.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/iterable-utility.d.ts +0 -39
- package/dist/iterable-utility.d.ts.map +0 -1
- package/dist/iterable-utility.js +0 -35
- package/dist/iterable-utility.js.map +0 -1
- package/dist/locale/en/locale-strings.d.ts +0 -32
- package/dist/locale/en/locale-strings.d.ts.map +0 -1
- package/dist/locale/en/locale-strings.js +0 -32
- package/dist/locale/en/locale-strings.js.map +0 -1
- package/dist/locale/fr/locale-strings.d.ts +0 -32
- package/dist/locale/fr/locale-strings.d.ts.map +0 -1
- package/dist/locale/fr/locale-strings.js +0 -32
- package/dist/locale/fr/locale-strings.js.map +0 -1
- package/dist/locale/i18n.d.ts +0 -27
- package/dist/locale/i18n.d.ts.map +0 -1
- package/dist/locale/i18n.js +0 -35
- package/dist/locale/i18n.js.map +0 -1
- package/dist/record.d.ts +0 -44
- package/dist/record.d.ts.map +0 -1
- package/dist/record.js +0 -58
- package/dist/record.js.map +0 -1
- package/dist/reg-exp.d.ts +0 -43
- package/dist/reg-exp.d.ts.map +0 -1
- package/dist/reg-exp.js +0 -55
- package/dist/reg-exp.js.map +0 -1
- package/dist/sequence.d.ts +0 -68
- package/dist/sequence.d.ts.map +0 -1
- package/dist/sequence.js +0 -96
- package/dist/sequence.js.map +0 -1
- package/dist/string.d.ts +0 -25
- package/dist/string.d.ts.map +0 -1
- package/dist/string.js +0 -2
- package/dist/string.js.map +0 -1
- package/dist/transformer.d.ts +0 -346
- package/dist/transformer.d.ts.map +0 -1
- package/dist/transformer.js +0 -456
- package/dist/transformer.js.map +0 -1
package/dist/character-set.js
DELETED
|
@@ -1,563 +0,0 @@
|
|
|
1
|
-
import { Exclusions } from "./exclusion.js";
|
|
2
|
-
import { i18nextUtility } from "./locale/i18n.js";
|
|
3
|
-
import { RegExpValidator } from "./reg-exp.js";
|
|
4
|
-
import { Transformer } from "./transformer.js";
|
|
5
|
-
/**
|
|
6
|
-
* Character set validator. Validates a string against a specified character set.
|
|
7
|
-
*/
|
|
8
|
-
export class CharacterSetValidator {
|
|
9
|
-
static NOT_ALL_NUMERIC_VALIDATOR = new class extends RegExpValidator {
|
|
10
|
-
/**
|
|
11
|
-
* Create an error message for an all-numeric string.
|
|
12
|
-
*
|
|
13
|
-
* @param _s
|
|
14
|
-
* String.
|
|
15
|
-
*
|
|
16
|
-
* @returns
|
|
17
|
-
* Error message.
|
|
18
|
-
*/
|
|
19
|
-
createErrorMessage(_s) {
|
|
20
|
-
return i18nextUtility.t("CharacterSetValidator.stringMustNotBeAllNumeric");
|
|
21
|
-
}
|
|
22
|
-
}(/\D/);
|
|
23
|
-
/**
|
|
24
|
-
* Character set.
|
|
25
|
-
*/
|
|
26
|
-
_characterSet;
|
|
27
|
-
/**
|
|
28
|
-
* Character set map, mapping each character in the character set to its index such that
|
|
29
|
-
* `_characterSetMap.get(_characterSet[index]) === index`.
|
|
30
|
-
*/
|
|
31
|
-
_characterSetMap;
|
|
32
|
-
/**
|
|
33
|
-
* Exclusions supported by the character set.
|
|
34
|
-
*/
|
|
35
|
-
_exclusionSupport;
|
|
36
|
-
/**
|
|
37
|
-
* Constructor.
|
|
38
|
-
*
|
|
39
|
-
* @param characterSet
|
|
40
|
-
* Character set. Each element is a single-character string, unique within the array, that defines the character
|
|
41
|
-
* set.
|
|
42
|
-
*
|
|
43
|
-
* @param exclusionSupport
|
|
44
|
-
* Exclusions supported by the character set. All character sets implicitly support {@link Exclusions.None}.
|
|
45
|
-
*/
|
|
46
|
-
constructor(characterSet, ...exclusionSupport) {
|
|
47
|
-
this._characterSet = characterSet;
|
|
48
|
-
const characterSetMap = new Map();
|
|
49
|
-
characterSet.forEach((c, index) => {
|
|
50
|
-
characterSetMap.set(c, index);
|
|
51
|
-
});
|
|
52
|
-
this._characterSetMap = characterSetMap;
|
|
53
|
-
this._exclusionSupport = exclusionSupport;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Get the character set.
|
|
57
|
-
*/
|
|
58
|
-
get characterSet() {
|
|
59
|
-
return this._characterSet;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get the character set size.
|
|
63
|
-
*/
|
|
64
|
-
get characterSetSize() {
|
|
65
|
-
return this._characterSet.length;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Get the exclusions supported by the character set.
|
|
69
|
-
*/
|
|
70
|
-
get exclusionSupport() {
|
|
71
|
-
return this._exclusionSupport;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Get the character at an index.
|
|
75
|
-
*
|
|
76
|
-
* @param index
|
|
77
|
-
* Index into the character set.
|
|
78
|
-
*
|
|
79
|
-
* @returns
|
|
80
|
-
* Character at the index.
|
|
81
|
-
*/
|
|
82
|
-
character(index) {
|
|
83
|
-
return this._characterSet[index];
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Get the index for a character.
|
|
87
|
-
*
|
|
88
|
-
* @param c
|
|
89
|
-
* Character.
|
|
90
|
-
*
|
|
91
|
-
* @returns
|
|
92
|
-
* Index for the character or undefined if the character is not in the character set.
|
|
93
|
-
*/
|
|
94
|
-
characterIndex(c) {
|
|
95
|
-
return this._characterSetMap.get(c);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Get the indexes for all characters in a string.
|
|
99
|
-
*
|
|
100
|
-
* @param s
|
|
101
|
-
* String.
|
|
102
|
-
*
|
|
103
|
-
* @returns
|
|
104
|
-
* Array of indexes for each character or undefined if the character is not in the character set.
|
|
105
|
-
*/
|
|
106
|
-
characterIndexes(s) {
|
|
107
|
-
return Array.from(s).map(c => this._characterSetMap.get(c));
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Convert a component definition to a string or undefined. Checks the type of the component and makes the callback
|
|
111
|
-
* if required.
|
|
112
|
-
*
|
|
113
|
-
* @param component
|
|
114
|
-
* Component definition as a string, callback, or undefined.
|
|
115
|
-
*
|
|
116
|
-
* @returns
|
|
117
|
-
* Component as a string or undefined.
|
|
118
|
-
*/
|
|
119
|
-
static componentToString(component) {
|
|
120
|
-
return typeof component === "function" ? component() : component;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Validate that an exclusion is supported. If not, an error is thrown.
|
|
124
|
-
*
|
|
125
|
-
* @param exclusion
|
|
126
|
-
* Exclusion.
|
|
127
|
-
*/
|
|
128
|
-
validateExclusion(exclusion) {
|
|
129
|
-
if (exclusion !== Exclusions.None && !this._exclusionSupport.includes(exclusion)) {
|
|
130
|
-
throw new RangeError(i18nextUtility.t("CharacterSetValidator.exclusionNotSupported", {
|
|
131
|
-
exclusion
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Validate a string. If the string violates the character set or any of the character set validation parameters, an
|
|
137
|
-
* error is thrown.
|
|
138
|
-
*
|
|
139
|
-
* @param s
|
|
140
|
-
* String.
|
|
141
|
-
*
|
|
142
|
-
* @param validation
|
|
143
|
-
* Character set validation parameters.
|
|
144
|
-
*/
|
|
145
|
-
validate(s, validation) {
|
|
146
|
-
const length = s.length;
|
|
147
|
-
const minimumLength = validation?.minimumLength;
|
|
148
|
-
const maximumLength = validation?.maximumLength;
|
|
149
|
-
if (minimumLength !== undefined && length < minimumLength) {
|
|
150
|
-
let errorMessage;
|
|
151
|
-
if (maximumLength !== undefined && maximumLength === minimumLength) {
|
|
152
|
-
errorMessage = i18nextUtility.t(validation?.component === undefined ? "CharacterSetValidator.lengthMustBeEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeEqualTo", {
|
|
153
|
-
component: CharacterSetValidator.componentToString(validation?.component),
|
|
154
|
-
length,
|
|
155
|
-
exactLength: minimumLength
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
errorMessage = i18nextUtility.t(validation?.component === undefined ? "CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeGreaterThanOrEqualTo", {
|
|
160
|
-
component: CharacterSetValidator.componentToString(validation?.component),
|
|
161
|
-
length,
|
|
162
|
-
minimumLength
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
throw new RangeError(errorMessage);
|
|
166
|
-
}
|
|
167
|
-
if (maximumLength !== undefined && length > maximumLength) {
|
|
168
|
-
throw new RangeError(i18nextUtility.t(validation?.component === undefined ? "CharacterSetValidator.lengthMustBeLessThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeLessThanOrEqualTo", {
|
|
169
|
-
component: CharacterSetValidator.componentToString(validation?.component),
|
|
170
|
-
length,
|
|
171
|
-
maximumLength
|
|
172
|
-
}));
|
|
173
|
-
}
|
|
174
|
-
// Find the index of the first character that is not in the character set.
|
|
175
|
-
const index = this.characterIndexes(s).findIndex(characterIndex => characterIndex === undefined);
|
|
176
|
-
if (index !== -1) {
|
|
177
|
-
throw new RangeError(i18nextUtility.t(validation?.component === undefined ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
|
|
178
|
-
component: CharacterSetValidator.componentToString(validation?.component),
|
|
179
|
-
c: s.charAt(index),
|
|
180
|
-
position: index + (validation?.positionOffset ?? 0) + 1
|
|
181
|
-
}));
|
|
182
|
-
}
|
|
183
|
-
if (validation?.exclusion !== undefined) {
|
|
184
|
-
this.validateExclusion(validation.exclusion);
|
|
185
|
-
switch (validation.exclusion) {
|
|
186
|
-
case Exclusions.None:
|
|
187
|
-
break;
|
|
188
|
-
case Exclusions.FirstZero:
|
|
189
|
-
if (s.startsWith("0")) {
|
|
190
|
-
throw new RangeError(i18nextUtility.t(validation.component === undefined ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
|
|
191
|
-
component: CharacterSetValidator.componentToString(validation.component),
|
|
192
|
-
c: "0",
|
|
193
|
-
position: (validation.positionOffset ?? 0) + 1
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
break;
|
|
197
|
-
case Exclusions.AllNumeric:
|
|
198
|
-
CharacterSetValidator.NOT_ALL_NUMERIC_VALIDATOR.validate(s);
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Character set creator. Maps numeric values to strings using the character set as digits.
|
|
206
|
-
*/
|
|
207
|
-
export class CharacterSetCreator extends CharacterSetValidator {
|
|
208
|
-
/**
|
|
209
|
-
* Maximum string length supported.
|
|
210
|
-
*/
|
|
211
|
-
static MAXIMUM_STRING_LENGTH = 40;
|
|
212
|
-
/**
|
|
213
|
-
* Powers of 10 from 1 (`10**0`) to `10**MAXIMUM_STRING_LENGTH`.
|
|
214
|
-
*/
|
|
215
|
-
static _powersOf10 = CharacterSetCreator.createPowersOf(10);
|
|
216
|
-
/**
|
|
217
|
-
* Create powers of a given base from 1 (`base**0`) to `base**MAXIMUM_STRING_LENGTH`.
|
|
218
|
-
*
|
|
219
|
-
* @param base
|
|
220
|
-
* Number base.
|
|
221
|
-
*
|
|
222
|
-
* @returns
|
|
223
|
-
* Array of powers of base.
|
|
224
|
-
*/
|
|
225
|
-
static createPowersOf(base) {
|
|
226
|
-
const powersOf = new Array(this.MAXIMUM_STRING_LENGTH + 1);
|
|
227
|
-
const baseN = BigInt(base);
|
|
228
|
-
for (let index = 0, powerOf = 1n; index <= this.MAXIMUM_STRING_LENGTH; index++, powerOf *= baseN) {
|
|
229
|
-
powersOf[index] = powerOf;
|
|
230
|
-
}
|
|
231
|
-
return powersOf;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Get a power of 10.
|
|
235
|
-
*
|
|
236
|
-
* @param power
|
|
237
|
-
* Power.
|
|
238
|
-
*
|
|
239
|
-
* @returns
|
|
240
|
-
* `10**power`.
|
|
241
|
-
*/
|
|
242
|
-
static powerOf10(power) {
|
|
243
|
-
return this._powersOf10[power];
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Character set size as big integer, cached for performance purposes.
|
|
247
|
-
*/
|
|
248
|
-
_characterSetSizeN;
|
|
249
|
-
/**
|
|
250
|
-
* Character set size minus 1 as big integer, cached for performance purposes.
|
|
251
|
-
*/
|
|
252
|
-
_characterSetSizeMinusOneN;
|
|
253
|
-
/**
|
|
254
|
-
* Domains for every length for every supported {@link Exclusions}.
|
|
255
|
-
*/
|
|
256
|
-
_exclusionDomains;
|
|
257
|
-
/**
|
|
258
|
-
* Values that would generate all zeros in the created string.
|
|
259
|
-
*/
|
|
260
|
-
_allZerosValues;
|
|
261
|
-
/**
|
|
262
|
-
* Constructor.
|
|
263
|
-
*
|
|
264
|
-
* @param characterSet
|
|
265
|
-
* Character set. Each element is a single-character string, unique within the array, that defines the character
|
|
266
|
-
* set.
|
|
267
|
-
*
|
|
268
|
-
* @param exclusionSupport
|
|
269
|
-
* Exclusions supported by the character set. All character sets implicitly support {@link Exclusions.None}.
|
|
270
|
-
*/
|
|
271
|
-
constructor(characterSet, ...exclusionSupport) {
|
|
272
|
-
super(characterSet, ...exclusionSupport);
|
|
273
|
-
this._characterSetSizeN = BigInt(this.characterSetSize);
|
|
274
|
-
this._characterSetSizeMinusOneN = BigInt(this.characterSetSize - 1);
|
|
275
|
-
const exclusionDomains = [];
|
|
276
|
-
const exclusionNoneDomains = CharacterSetCreator.createPowersOf(this.characterSetSize);
|
|
277
|
-
exclusionDomains[Exclusions.None] = exclusionNoneDomains;
|
|
278
|
-
if (exclusionSupport.includes(Exclusions.FirstZero)) {
|
|
279
|
-
if (characterSet[0] !== "0") {
|
|
280
|
-
throw new RangeError(i18nextUtility.t("CharacterSetValidator.firstZeroFirstCharacter"));
|
|
281
|
-
}
|
|
282
|
-
const exclusionFirstZeroDomains = new Array(CharacterSetCreator.MAXIMUM_STRING_LENGTH + 1);
|
|
283
|
-
// Exclusion of first zero mathematically prohibits length of 0.
|
|
284
|
-
exclusionFirstZeroDomains[0] = 0n;
|
|
285
|
-
for (let index = 1; index <= CharacterSetCreator.MAXIMUM_STRING_LENGTH; index++) {
|
|
286
|
-
// Domain excludes zero as the first character and so works with previous exclusion none domain.
|
|
287
|
-
exclusionFirstZeroDomains[index] = this._characterSetSizeMinusOneN * exclusionNoneDomains[index - 1];
|
|
288
|
-
}
|
|
289
|
-
exclusionDomains[Exclusions.FirstZero] = exclusionFirstZeroDomains;
|
|
290
|
-
}
|
|
291
|
-
if (exclusionSupport.includes(Exclusions.AllNumeric)) {
|
|
292
|
-
const exclusionAllNumericDomains = new Array(CharacterSetCreator.MAXIMUM_STRING_LENGTH + 1);
|
|
293
|
-
/**
|
|
294
|
-
* Validate that number indexes are defined and sequential.
|
|
295
|
-
*
|
|
296
|
-
* @param numberIndexes
|
|
297
|
-
* Number indexes.
|
|
298
|
-
*/
|
|
299
|
-
function validateNumberIndexes(numberIndexes) {
|
|
300
|
-
let expectedNumberIndex = numberIndexes[0];
|
|
301
|
-
// Make sure that all numeric characters are present and in sequence.
|
|
302
|
-
for (const numberIndex of numberIndexes) {
|
|
303
|
-
if (numberIndex === undefined || numberIndex !== expectedNumberIndex) {
|
|
304
|
-
throw new RangeError(i18nextUtility.t("CharacterSetValidator.allNumericAllNumericCharacters"));
|
|
305
|
-
}
|
|
306
|
-
expectedNumberIndex = numberIndex + 1;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
const numberIndexes = this.characterIndexes("0123456789");
|
|
310
|
-
validateNumberIndexes(numberIndexes);
|
|
311
|
-
// Zero index is the all-zero value for a single-character string.
|
|
312
|
-
const zeroIndex = BigInt(numberIndexes[0]);
|
|
313
|
-
const allZerosValues = new Array(CharacterSetCreator.MAXIMUM_STRING_LENGTH + 1);
|
|
314
|
-
let allZerosValue = 0n;
|
|
315
|
-
// Each all-zero value is the previous all-zero value multiplied by the character set size plus the zero index.
|
|
316
|
-
for (let index = 0; index <= CharacterSetCreator.MAXIMUM_STRING_LENGTH; index++) {
|
|
317
|
-
// Domain excludes the number of permutations that would result in an all-numeric string.
|
|
318
|
-
exclusionAllNumericDomains[index] = exclusionNoneDomains[index] - CharacterSetCreator.powerOf10(index);
|
|
319
|
-
allZerosValues[index] = allZerosValue;
|
|
320
|
-
allZerosValue = allZerosValue * this._characterSetSizeN + zeroIndex;
|
|
321
|
-
}
|
|
322
|
-
this._allZerosValues = allZerosValues;
|
|
323
|
-
exclusionDomains[Exclusions.AllNumeric] = exclusionAllNumericDomains;
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
// Empty array obviates need for non-null assertion while still forcing error if indexed due to a bug.
|
|
327
|
-
this._allZerosValues = [];
|
|
328
|
-
}
|
|
329
|
-
this._exclusionDomains = exclusionDomains;
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Get a power of character set size.
|
|
333
|
-
*
|
|
334
|
-
* @param power
|
|
335
|
-
* Power.
|
|
336
|
-
*
|
|
337
|
-
* @returns
|
|
338
|
-
* `characterSetSize**power`.
|
|
339
|
-
*/
|
|
340
|
-
powerOfSize(power) {
|
|
341
|
-
return this._exclusionDomains[Exclusions.None][power];
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Determine the shift required to skip all all-numeric strings up to the value.
|
|
345
|
-
*
|
|
346
|
-
* @param shiftForward
|
|
347
|
-
* True to shift forward (value to string), false to shift backward (string to value).
|
|
348
|
-
*
|
|
349
|
-
* @param length
|
|
350
|
-
* Length of string for which to get the all-numeric shift.
|
|
351
|
-
*
|
|
352
|
-
* @param value
|
|
353
|
-
* Value for which to get the all-numeric shift.
|
|
354
|
-
*
|
|
355
|
-
* @returns
|
|
356
|
-
* Shift required to skip all all-numeric strings.
|
|
357
|
-
*/
|
|
358
|
-
allNumericShift(shiftForward, length, value) {
|
|
359
|
-
let shift;
|
|
360
|
-
if (length === 0) {
|
|
361
|
-
if (!shiftForward && value < 10n) {
|
|
362
|
-
// If calculation gets this far, string is all-numeric.
|
|
363
|
-
throw new RangeError(i18nextUtility.t("CharacterSetValidator.stringMustNotBeAllNumeric"));
|
|
364
|
-
}
|
|
365
|
-
// Now dealing with individual characters; shift by 10 to skip numeric characters.
|
|
366
|
-
shift = 10n;
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
const powerOfSize = this.powerOfSize(length);
|
|
370
|
-
const powerOf10 = CharacterSetCreator.powerOf10(length);
|
|
371
|
-
// Calculate the gap to the next numeric string of equal length with incremental first character.
|
|
372
|
-
const gap = shiftForward ? powerOfSize - powerOf10 : powerOfSize;
|
|
373
|
-
// Determine the number of gaps remaining in the value.
|
|
374
|
-
const gaps = value / gap;
|
|
375
|
-
if (gaps >= 10n) {
|
|
376
|
-
// Shift is the next power of 10.
|
|
377
|
-
shift = CharacterSetCreator.powerOf10(length + 1);
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
// Shift is the number of gaps times the current power of 10 plus the shift for the next length down with value adjusted by the number of gaps times the gap.
|
|
381
|
-
shift = gaps * powerOf10 + this.allNumericShift(shiftForward, length - 1, value - gaps * gap);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
return shift;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Validate that a length is less than or equal to {@link MAXIMUM_STRING_LENGTH}. If not, an error is thrown.
|
|
388
|
-
*
|
|
389
|
-
* @param length
|
|
390
|
-
* Length.
|
|
391
|
-
*/
|
|
392
|
-
validateLength(length) {
|
|
393
|
-
if (length < 0) {
|
|
394
|
-
throw new RangeError(i18nextUtility.t("CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo", {
|
|
395
|
-
length,
|
|
396
|
-
minimumLength: 0
|
|
397
|
-
}));
|
|
398
|
-
}
|
|
399
|
-
if (length > CharacterSetCreator.MAXIMUM_STRING_LENGTH) {
|
|
400
|
-
throw new RangeError(i18nextUtility.t("CharacterSetValidator.lengthMustBeLessThanOrEqualTo", {
|
|
401
|
-
length,
|
|
402
|
-
maximumLength: CharacterSetCreator.MAXIMUM_STRING_LENGTH
|
|
403
|
-
}));
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Create string(s) by mapping value(s) to the equivalent characters in the character set across the length of the
|
|
408
|
-
* string.
|
|
409
|
-
*
|
|
410
|
-
* @template TTransformerInput
|
|
411
|
-
* Transformer input type.
|
|
412
|
-
*
|
|
413
|
-
* @param length
|
|
414
|
-
* Required string length.
|
|
415
|
-
*
|
|
416
|
-
* @param valueOrValues
|
|
417
|
-
* Numeric value(s) of the string(s).
|
|
418
|
-
*
|
|
419
|
-
* @param exclusion
|
|
420
|
-
* String(s) to be excluded from the range of outputs. See {@link Exclusions} for possible values and their meaning.
|
|
421
|
-
*
|
|
422
|
-
* @param tweak
|
|
423
|
-
* If provided, the numerical value of the string(s) is/are "tweaked" using an {@link EncryptionTransformer |
|
|
424
|
-
* encryption transformer}.
|
|
425
|
-
*
|
|
426
|
-
* @param creatorCallback
|
|
427
|
-
* If provided, called after each string is constructed to create the final value.
|
|
428
|
-
*
|
|
429
|
-
* @returns
|
|
430
|
-
* String(s) created from the value(s).
|
|
431
|
-
*/
|
|
432
|
-
create(length, valueOrValues, exclusion = Exclusions.None, tweak, creatorCallback) {
|
|
433
|
-
this.validateLength(length);
|
|
434
|
-
this.validateExclusion(exclusion);
|
|
435
|
-
// Zero value in ternary else obviates need for non-null assertion.
|
|
436
|
-
const allZerosValue = exclusion === Exclusions.AllNumeric ? this._allZerosValues[length] : 0n;
|
|
437
|
-
const transformer = Transformer.get(this._exclusionDomains[exclusion][length], tweak);
|
|
438
|
-
return transformer.forward(valueOrValues, (transformedValue, index) => {
|
|
439
|
-
let s = "";
|
|
440
|
-
// Empty string is valid.
|
|
441
|
-
if (length !== 0) {
|
|
442
|
-
let convertValue = transformedValue;
|
|
443
|
-
if (exclusion === Exclusions.AllNumeric && convertValue >= allZerosValue) {
|
|
444
|
-
// Value to convert is shifted by the number of all-numeric strings that occur at or prior to it.
|
|
445
|
-
convertValue = convertValue + this.allNumericShift(true, length, convertValue - allZerosValue);
|
|
446
|
-
}
|
|
447
|
-
// Build string from right to left excluding the first character.
|
|
448
|
-
for (let position = length - 1; position > 0; position--) {
|
|
449
|
-
const nextConvertValue = convertValue / this._characterSetSizeN;
|
|
450
|
-
// First step is effectively a modulus calculation.
|
|
451
|
-
s = this.character(Number(convertValue - nextConvertValue * this._characterSetSizeN)) + s;
|
|
452
|
-
convertValue = nextConvertValue;
|
|
453
|
-
}
|
|
454
|
-
// Zero is first in the character set for those that support excluding first zero.
|
|
455
|
-
s = this.character(exclusion === Exclusions.FirstZero ? Number(convertValue % this._characterSetSizeMinusOneN) + 1 : Number(convertValue % this._characterSetSizeN)) + s;
|
|
456
|
-
}
|
|
457
|
-
return creatorCallback === undefined ? s : creatorCallback(s, index);
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Determine the value for a string.
|
|
462
|
-
*
|
|
463
|
-
* @param s
|
|
464
|
-
* String.
|
|
465
|
-
*
|
|
466
|
-
* @param exclusion
|
|
467
|
-
* Strings excluded from the range of inputs. See {@link Exclusions} for possible values and their meaning.
|
|
468
|
-
*
|
|
469
|
-
* @param tweak
|
|
470
|
-
* If provided, the numerical value of the string was "tweaked" using an {@link EncryptionTransformer | encryption
|
|
471
|
-
* transformer}.
|
|
472
|
-
*
|
|
473
|
-
* @returns
|
|
474
|
-
* Numeric value of the string.
|
|
475
|
-
*/
|
|
476
|
-
valueFor(s, exclusion = Exclusions.None, tweak) {
|
|
477
|
-
const length = s.length;
|
|
478
|
-
this.validateLength(length);
|
|
479
|
-
this.validateExclusion(exclusion);
|
|
480
|
-
const characterSetSizeN = BigInt(this.characterSetSize);
|
|
481
|
-
// Convert string to its value character by character.
|
|
482
|
-
let value = this.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
|
|
483
|
-
if (characterIndex === undefined) {
|
|
484
|
-
throw new RangeError(i18nextUtility.t("CharacterSetValidator.invalidCharacterAtPosition", {
|
|
485
|
-
c: s.charAt(index),
|
|
486
|
-
position: index + 1
|
|
487
|
-
}));
|
|
488
|
-
}
|
|
489
|
-
let value;
|
|
490
|
-
if (index === 0 && exclusion === Exclusions.FirstZero) {
|
|
491
|
-
if (characterIndex === 0) {
|
|
492
|
-
throw new RangeError(i18nextUtility.t("CharacterSetValidator.invalidCharacterAtPosition", {
|
|
493
|
-
c: "0",
|
|
494
|
-
position: 1
|
|
495
|
-
}));
|
|
496
|
-
}
|
|
497
|
-
// Accumulator is known to be zero at this point.
|
|
498
|
-
value = BigInt(characterIndex - 1);
|
|
499
|
-
}
|
|
500
|
-
else {
|
|
501
|
-
value = accumulator * characterSetSizeN + BigInt(characterIndex);
|
|
502
|
-
}
|
|
503
|
-
return value;
|
|
504
|
-
}, 0n);
|
|
505
|
-
if (exclusion === Exclusions.AllNumeric) {
|
|
506
|
-
const allZerosValue = this._allZerosValues[length];
|
|
507
|
-
if (value >= allZerosValue) {
|
|
508
|
-
// Call will ensure that string is not all-numeric.
|
|
509
|
-
value -= this.allNumericShift(false, length, value - allZerosValue);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
return Transformer.get(this._exclusionDomains[exclusion][length], tweak).reverse(value);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Numeric creator. Character set is 0-9. Supports {@link Exclusions.FirstZero}.
|
|
517
|
-
*/
|
|
518
|
-
export const NUMERIC_CREATOR = new CharacterSetCreator([
|
|
519
|
-
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
|
|
520
|
-
], Exclusions.FirstZero);
|
|
521
|
-
/**
|
|
522
|
-
* Numeric validator. Character set is 0-9. Supports {@link Exclusions.FirstZero}.
|
|
523
|
-
*/
|
|
524
|
-
export const NUMERIC_VALIDATOR = NUMERIC_CREATOR;
|
|
525
|
-
/**
|
|
526
|
-
* Hexadecimal creator. Character set is 0-9, A-F. Supports {@link Exclusions.FirstZero} and {@link
|
|
527
|
-
* Exclusions.AllNumeric}.
|
|
528
|
-
*/
|
|
529
|
-
export const HEXADECIMAL_CREATOR = new CharacterSetCreator([
|
|
530
|
-
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
531
|
-
"A", "B", "C", "D", "E", "F"
|
|
532
|
-
], Exclusions.FirstZero, Exclusions.AllNumeric);
|
|
533
|
-
/**
|
|
534
|
-
* Hexadecimal validator. Character set is 0-9, A-F. Supports {@link Exclusions.FirstZero} and {@link
|
|
535
|
-
* Exclusions.AllNumeric}.
|
|
536
|
-
*/
|
|
537
|
-
export const HEXADECIMAL_VALIDATOR = HEXADECIMAL_CREATOR;
|
|
538
|
-
/**
|
|
539
|
-
* Alphabetic creator. Character set is A-Z.
|
|
540
|
-
*/
|
|
541
|
-
export const ALPHABETIC_CREATOR = new CharacterSetCreator([
|
|
542
|
-
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
|
543
|
-
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
|
|
544
|
-
]);
|
|
545
|
-
/**
|
|
546
|
-
* Alphabetic validator. Character set is A-Z.
|
|
547
|
-
*/
|
|
548
|
-
export const ALPHABETIC_VALIDATOR = ALPHABETIC_CREATOR;
|
|
549
|
-
/**
|
|
550
|
-
* Alphanumeric creator. Character set is 0-9, A-Z. Supports {@link Exclusions.FirstZero} and {@link
|
|
551
|
-
* Exclusions.AllNumeric}.
|
|
552
|
-
*/
|
|
553
|
-
export const ALPHANUMERIC_CREATOR = new CharacterSetCreator([
|
|
554
|
-
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
555
|
-
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
|
556
|
-
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
|
|
557
|
-
], Exclusions.FirstZero, Exclusions.AllNumeric);
|
|
558
|
-
/**
|
|
559
|
-
* Alphanumeric validator. Character set is 0-9, A-Z. Supports {@link Exclusions.FirstZero} and {@link
|
|
560
|
-
* Exclusions.AllNumeric}.
|
|
561
|
-
*/
|
|
562
|
-
export const ALPHANUMERIC_VALIDATOR = ALPHANUMERIC_CREATOR;
|
|
563
|
-
//# sourceMappingURL=character-set.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"character-set.js","sourceRoot":"","sources":["../src/character-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAiD,MAAM,kBAAkB,CAAC;AAmC9F;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACtB,MAAM,CAAU,yBAAyB,GAAG,IAAI,KAAM,SAAQ,eAAe;QACjF;;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GAAG,EAAE,GAAG;IAC/D,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;CAClE,EAAE,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAA6C,CAAC"}
|
package/dist/exclusion.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exclusion options for validating and creating strings based on character sets.
|
|
3
|
-
*/
|
|
4
|
-
export declare const Exclusions: {
|
|
5
|
-
/**
|
|
6
|
-
* No strings excluded.
|
|
7
|
-
*/
|
|
8
|
-
readonly None: 0;
|
|
9
|
-
/**
|
|
10
|
-
* Strings that start with zero ('0') excluded.
|
|
11
|
-
*/
|
|
12
|
-
readonly FirstZero: 1;
|
|
13
|
-
/**
|
|
14
|
-
* Strings that are all-numeric (e.g., "123456") excluded.
|
|
15
|
-
*/
|
|
16
|
-
readonly AllNumeric: 2;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Exclusion.
|
|
20
|
-
*/
|
|
21
|
-
export type Exclusion = typeof Exclusions[keyof typeof Exclusions];
|
|
22
|
-
//# sourceMappingURL=exclusion.d.ts.map
|
package/dist/exclusion.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exclusion.d.ts","sourceRoot":"","sources":["../src/exclusion.ts"],"names":[],"mappings":"AAAA;;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"}
|
package/dist/exclusion.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exclusion options for validating and creating strings based on character sets.
|
|
3
|
-
*/
|
|
4
|
-
export const Exclusions = {
|
|
5
|
-
/**
|
|
6
|
-
* No strings excluded.
|
|
7
|
-
*/
|
|
8
|
-
None: 0,
|
|
9
|
-
/**
|
|
10
|
-
* Strings that start with zero ('0') excluded.
|
|
11
|
-
*/
|
|
12
|
-
FirstZero: 1,
|
|
13
|
-
/**
|
|
14
|
-
* Strings that are all-numeric (e.g., "123456") excluded.
|
|
15
|
-
*/
|
|
16
|
-
AllNumeric: 2
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=exclusion.js.map
|
package/dist/exclusion.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exclusion.js","sourceRoot":"","sources":["../src/exclusion.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB;;OAEG;IACH,IAAI,EAAE,CAAC;IAEP;;OAEG;IACH,SAAS,EAAE,CAAC;IAEZ;;OAEG;IACH,UAAU,EAAE,CAAC;CACP,CAAC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,mBAAmB,aAAa,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Indexed callback, used to map an input and optionally its index in an iterable to an output.
|
|
3
|
-
*
|
|
4
|
-
* @template TInput
|
|
5
|
-
* Input type.
|
|
6
|
-
*
|
|
7
|
-
* @template TOutput
|
|
8
|
-
* Output type.
|
|
9
|
-
*
|
|
10
|
-
* @param input
|
|
11
|
-
* Input value.
|
|
12
|
-
*
|
|
13
|
-
* @param index
|
|
14
|
-
* Index in iterable or undefined for single mapping).
|
|
15
|
-
*
|
|
16
|
-
* @returns
|
|
17
|
-
* Output value.
|
|
18
|
-
*/
|
|
19
|
-
export type IndexedCallback<TInput, TOutput> = (input: TInput, index?: number) => TOutput;
|
|
20
|
-
/**
|
|
21
|
-
* Map an input iterable to an output iterable that applies a transformer callback to each value in the input.
|
|
22
|
-
*
|
|
23
|
-
* @template TInput
|
|
24
|
-
* Input type.
|
|
25
|
-
*
|
|
26
|
-
* @template TOutput
|
|
27
|
-
* Output type.
|
|
28
|
-
*
|
|
29
|
-
* @param values
|
|
30
|
-
* Input values iterable.
|
|
31
|
-
*
|
|
32
|
-
* @param indexedCallback
|
|
33
|
-
* Callback to transform input value to output value.
|
|
34
|
-
*
|
|
35
|
-
* @returns
|
|
36
|
-
* Output values iterable.
|
|
37
|
-
*/
|
|
38
|
-
export declare function mapIterable<TInput, TOutput>(values: Iterable<TInput>, indexedCallback: IndexedCallback<TInput, TOutput>): Iterable<TOutput>;
|
|
39
|
-
//# sourceMappingURL=iterable-utility.d.ts.map
|