@aidc-toolkit/utility 0.9.7-beta → 0.9.8-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/index.cjs +91 -482
- package/dist/index.d.cts +611 -65
- package/dist/index.d.ts +611 -65
- package/dist/index.js +77 -481
- package/package.json +5 -4
- package/src/{character_set.ts → character-set.ts} +17 -36
- package/src/index.ts +3 -5
- package/src/locale/i18n.ts +37 -6
- package/src/locale/i18next.d.ts +3 -3
- package/src/record.ts +3 -4
- package/src/{reg_exp.ts → reg-exp.ts} +2 -3
- package/src/sequencer.ts +8 -50
- package/src/transformer.ts +89 -23
- package/test/{character_set.test.ts → character-set.test.ts} +3 -2
- package/test/record.test.ts +3 -3
- package/test/{reg_exp.test.ts → reg-exp.test.ts} +3 -3
- package/test/sequencer.test.ts +10 -21
- package/test/transformer.test.ts +31 -3
- package/src/iterator_proxy.ts +0 -517
- package/src/types.ts +0 -46
- package/test/iterator_proxy.test.ts +0 -252
- /package/src/locale/en/{locale_strings.ts → locale-strings.ts} +0 -0
- /package/src/locale/fr/{locale_strings.ts → locale-strings.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -28,20 +38,24 @@ __export(src_exports, {
|
|
|
28
38
|
Exclusion: () => Exclusion,
|
|
29
39
|
HEXADECIMAL_CREATOR: () => HEXADECIMAL_CREATOR,
|
|
30
40
|
IdentityTransformer: () => IdentityTransformer,
|
|
31
|
-
IteratorProxy: () => IteratorProxy,
|
|
32
41
|
NUMERIC_CREATOR: () => NUMERIC_CREATOR,
|
|
33
42
|
RecordValidator: () => RecordValidator,
|
|
34
43
|
RegExpValidator: () => RegExpValidator,
|
|
35
44
|
Sequencer: () => Sequencer,
|
|
36
45
|
Transformer: () => Transformer,
|
|
37
|
-
|
|
46
|
+
i18nUtilityInit: () => i18nUtilityInit,
|
|
47
|
+
i18nextUtility: () => i18nextUtility,
|
|
48
|
+
transformIterable: () => transformIterable,
|
|
49
|
+
utilityNS: () => utilityNS,
|
|
50
|
+
utilityResources: () => utilityResources
|
|
38
51
|
});
|
|
39
52
|
module.exports = __toCommonJS(src_exports);
|
|
40
53
|
|
|
41
54
|
// src/locale/i18n.ts
|
|
42
55
|
var import_core = require("@aidc-toolkit/core");
|
|
56
|
+
var import_i18next = __toESM(require("i18next"), 1);
|
|
43
57
|
|
|
44
|
-
// src/locale/en/
|
|
58
|
+
// src/locale/en/locale-strings.ts
|
|
45
59
|
var localeStrings = {
|
|
46
60
|
Transformer: {
|
|
47
61
|
domainMustBeGreaterThanZero: "Domain {{domain}} must be greater than 0",
|
|
@@ -75,7 +89,7 @@ var localeStrings = {
|
|
|
75
89
|
}
|
|
76
90
|
};
|
|
77
91
|
|
|
78
|
-
// src/locale/fr/
|
|
92
|
+
// src/locale/fr/locale-strings.ts
|
|
79
93
|
var localeStrings2 = {
|
|
80
94
|
Transformer: {
|
|
81
95
|
domainMustBeGreaterThanZero: "Le domaine {{domain}} doit \xEAtre sup\xE9rieur \xE0 0",
|
|
@@ -112,386 +126,18 @@ var localeStrings2 = {
|
|
|
112
126
|
// src/locale/i18n.ts
|
|
113
127
|
var utilityNS = "aidct_utility";
|
|
114
128
|
(0, import_core.i18nAssertValidResources)(localeStrings, "fr", localeStrings2);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Convert an iteration source to an iterable.
|
|
123
|
-
*
|
|
124
|
-
* @param iterationSource
|
|
125
|
-
* Iteration source.
|
|
126
|
-
*
|
|
127
|
-
* @returns
|
|
128
|
-
* Iteration source if it is already an iterable, otherwise iteration source wrapped in an iterable.
|
|
129
|
-
*/
|
|
130
|
-
static toIterable(iterationSource) {
|
|
131
|
-
return Symbol.iterator in iterationSource ? iterationSource : {
|
|
132
|
-
[Symbol.iterator]() {
|
|
133
|
-
return iterationSource;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Initial iterable.
|
|
139
|
-
*/
|
|
140
|
-
_initialIterable;
|
|
141
|
-
/**
|
|
142
|
-
* Initial iterator.
|
|
143
|
-
*/
|
|
144
|
-
_initialIterator;
|
|
145
|
-
/**
|
|
146
|
-
* Constructor.
|
|
147
|
-
*
|
|
148
|
-
* @param initialIterationSource
|
|
149
|
-
* Initial iteration source.
|
|
150
|
-
*/
|
|
151
|
-
constructor(initialIterationSource) {
|
|
152
|
-
this._initialIterable = _IteratorProxyBase.toIterable(initialIterationSource);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Get the initial iterable.
|
|
156
|
-
*/
|
|
157
|
-
get initialIterable() {
|
|
158
|
-
return this._initialIterable;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Get the initial iterator.
|
|
162
|
-
*/
|
|
163
|
-
get initialIterator() {
|
|
164
|
-
if (this._initialIterator === void 0) {
|
|
165
|
-
this._initialIterator = this.initialIterable[Symbol.iterator]();
|
|
166
|
-
}
|
|
167
|
-
return this._initialIterator;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* @inheritDoc
|
|
171
|
-
*/
|
|
172
|
-
get [Symbol.toStringTag]() {
|
|
173
|
-
return "IteratorProxy";
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* @inheritDoc
|
|
177
|
-
*/
|
|
178
|
-
[Symbol.dispose]() {
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* @inheritDoc
|
|
182
|
-
*/
|
|
183
|
-
[Symbol.iterator]() {
|
|
184
|
-
return this;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Get the next result from the initial iterator.
|
|
188
|
-
*
|
|
189
|
-
* @param value
|
|
190
|
-
* Tuple value to be passed to Iterator.next().
|
|
191
|
-
*
|
|
192
|
-
* @returns
|
|
193
|
-
* Next result from the initial iterator.
|
|
194
|
-
*/
|
|
195
|
-
initialNext(...value) {
|
|
196
|
-
return this.initialIterator.next(...value);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* @inheritDoc
|
|
200
|
-
*/
|
|
201
|
-
map(callback) {
|
|
202
|
-
return new IteratorMapProxy(this, callback);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* @inheritDoc
|
|
206
|
-
*/
|
|
207
|
-
flatMap(callback) {
|
|
208
|
-
return new IteratorFlatMapProxy(this, callback);
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* @inheritDoc
|
|
212
|
-
*/
|
|
213
|
-
filter(predicate) {
|
|
214
|
-
return new IteratorFilterProxy(this, predicate, true);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* @inheritDoc
|
|
218
|
-
*/
|
|
219
|
-
take(limit) {
|
|
220
|
-
return new IteratorTakeProxy(this, limit);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* @inheritDoc
|
|
224
|
-
*/
|
|
225
|
-
drop(count) {
|
|
226
|
-
return new IteratorDropProxy(this, count);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* @inheritDoc
|
|
230
|
-
*/
|
|
231
|
-
reduce(callback, initialValue) {
|
|
232
|
-
let index = 0;
|
|
233
|
-
let result = initialValue;
|
|
234
|
-
for (const value of this) {
|
|
235
|
-
if (index === 0 && arguments.length === 1) {
|
|
236
|
-
result = value;
|
|
237
|
-
} else {
|
|
238
|
-
result = callback(result, value, index);
|
|
239
|
-
}
|
|
240
|
-
index++;
|
|
241
|
-
}
|
|
242
|
-
if (index === 0 && arguments.length === 1) {
|
|
243
|
-
throw new Error("reduce() of empty iterator with no initial value");
|
|
244
|
-
}
|
|
245
|
-
return result;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* @inheritDoc
|
|
249
|
-
*/
|
|
250
|
-
toArray() {
|
|
251
|
-
return Array.from(this);
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* @inheritDoc
|
|
255
|
-
*/
|
|
256
|
-
forEach(callback) {
|
|
257
|
-
let index = 0;
|
|
258
|
-
for (const element of this) {
|
|
259
|
-
callback(element, index++);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* @inheritDoc
|
|
264
|
-
*/
|
|
265
|
-
some(predicate) {
|
|
266
|
-
return new IteratorFilterProxy(this, predicate, true).next().done !== true;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* @inheritDoc
|
|
270
|
-
*/
|
|
271
|
-
every(predicate) {
|
|
272
|
-
return new IteratorFilterProxy(this, predicate, false).next().done === true;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* @inheritDoc
|
|
276
|
-
*/
|
|
277
|
-
find(predicate) {
|
|
278
|
-
return new IteratorFilterProxy(this, predicate, true).next().value;
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
var IteratorProxyObject = class extends IteratorProxyBase {
|
|
282
|
-
/**
|
|
283
|
-
* @inheritDoc
|
|
284
|
-
*/
|
|
285
|
-
next(...value) {
|
|
286
|
-
return this.initialNext(...value);
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
var IteratorMapProxyBase = class extends IteratorProxyBase {
|
|
290
|
-
/**
|
|
291
|
-
* Callback.
|
|
292
|
-
*/
|
|
293
|
-
_callback;
|
|
294
|
-
/**
|
|
295
|
-
* Index into initial iteration source.
|
|
296
|
-
*/
|
|
297
|
-
_index;
|
|
298
|
-
/**
|
|
299
|
-
* Constructor.
|
|
300
|
-
*
|
|
301
|
-
* @param initialIterationSource
|
|
302
|
-
* Initial iteration source.
|
|
303
|
-
*
|
|
304
|
-
* @param callback
|
|
305
|
-
* Callback.
|
|
306
|
-
*/
|
|
307
|
-
constructor(initialIterationSource, callback) {
|
|
308
|
-
super(initialIterationSource);
|
|
309
|
-
this._callback = callback;
|
|
310
|
-
this._index = 0;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Get the next result from the intermediate iterator.
|
|
314
|
-
*
|
|
315
|
-
* @param value
|
|
316
|
-
* Tuple value to be passed to Iterator.next().
|
|
317
|
-
*
|
|
318
|
-
* @returns
|
|
319
|
-
* Next result from the intermediate iterator.
|
|
320
|
-
*/
|
|
321
|
-
intermediateNext(...value) {
|
|
322
|
-
const initialResult = this.initialNext(...value);
|
|
323
|
-
return initialResult.done !== true ? {
|
|
324
|
-
value: this._callback(initialResult.value, this._index++)
|
|
325
|
-
} : {
|
|
326
|
-
done: true,
|
|
327
|
-
value: void 0
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
var IteratorMapProxy = class extends IteratorMapProxyBase {
|
|
332
|
-
/**
|
|
333
|
-
* @inheritDoc
|
|
334
|
-
*/
|
|
335
|
-
next(...value) {
|
|
336
|
-
return this.intermediateNext(...value);
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
var IteratorFlatMapProxy = class extends IteratorMapProxyBase {
|
|
340
|
-
_intermediateIterator;
|
|
341
|
-
/**
|
|
342
|
-
* @inheritDoc
|
|
343
|
-
*/
|
|
344
|
-
next(...value) {
|
|
345
|
-
let finalResult = void 0;
|
|
346
|
-
do {
|
|
347
|
-
if (this._intermediateIterator === void 0) {
|
|
348
|
-
const intermediateResult = this.intermediateNext(...value);
|
|
349
|
-
if (intermediateResult.done === true) {
|
|
350
|
-
finalResult = intermediateResult;
|
|
351
|
-
} else {
|
|
352
|
-
this._intermediateIterator = IteratorProxyBase.toIterable(intermediateResult.value)[Symbol.iterator]();
|
|
353
|
-
}
|
|
354
|
-
} else {
|
|
355
|
-
const pendingFinalResult = this._intermediateIterator.next();
|
|
356
|
-
if (pendingFinalResult.done === true) {
|
|
357
|
-
this._intermediateIterator = void 0;
|
|
358
|
-
} else {
|
|
359
|
-
finalResult = pendingFinalResult;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
} while (finalResult === void 0);
|
|
363
|
-
return finalResult;
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
var IteratorFilterProxy = class extends IteratorProxyBase {
|
|
367
|
-
/**
|
|
368
|
-
* Predicate.
|
|
369
|
-
*/
|
|
370
|
-
_predicate;
|
|
371
|
-
/**
|
|
372
|
-
* Expected truthy result of the predicate.
|
|
373
|
-
*/
|
|
374
|
-
_expectedTruthy;
|
|
375
|
-
/**
|
|
376
|
-
* Index into iteration source.
|
|
377
|
-
*/
|
|
378
|
-
_index;
|
|
379
|
-
/**
|
|
380
|
-
* Constructor.
|
|
381
|
-
*
|
|
382
|
-
* @param iterationSource
|
|
383
|
-
* Iteration source.
|
|
384
|
-
*
|
|
385
|
-
* @param predicate
|
|
386
|
-
* Predicate.
|
|
387
|
-
*
|
|
388
|
-
* @param expectedTruthy
|
|
389
|
-
* Expected truthy result of the predicate.
|
|
390
|
-
*/
|
|
391
|
-
constructor(iterationSource, predicate, expectedTruthy) {
|
|
392
|
-
super(iterationSource);
|
|
393
|
-
this._predicate = predicate;
|
|
394
|
-
this._expectedTruthy = expectedTruthy;
|
|
395
|
-
this._index = 0;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* @inheritDoc
|
|
399
|
-
*/
|
|
400
|
-
next(...value) {
|
|
401
|
-
let result;
|
|
402
|
-
const expectedTruthy = this._expectedTruthy;
|
|
403
|
-
do {
|
|
404
|
-
result = this.initialNext(...value);
|
|
405
|
-
} while (result.done !== true && Boolean(this._predicate(result.value, this._index++)) !== expectedTruthy);
|
|
406
|
-
return result;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
var IteratorCountProxyBase = class extends IteratorProxyObject {
|
|
410
|
-
/**
|
|
411
|
-
* Count.
|
|
412
|
-
*/
|
|
413
|
-
_count;
|
|
414
|
-
/**
|
|
415
|
-
* Constructor.
|
|
416
|
-
*
|
|
417
|
-
* @param initialIterationSource
|
|
418
|
-
* Initial iteration source.
|
|
419
|
-
*
|
|
420
|
-
* @param count
|
|
421
|
-
* Count.
|
|
422
|
-
*/
|
|
423
|
-
constructor(initialIterationSource, count) {
|
|
424
|
-
super(initialIterationSource);
|
|
425
|
-
if (!Number.isInteger(count) || count < 0) {
|
|
426
|
-
throw new RangeError("Count must be a positive integer");
|
|
427
|
-
}
|
|
428
|
-
this._count = count;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Determine if iterator is exhausted (by count or by iterator itself).
|
|
432
|
-
*/
|
|
433
|
-
get exhausted() {
|
|
434
|
-
return this._count <= 0;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* @inheritDoc
|
|
438
|
-
*/
|
|
439
|
-
next(...value) {
|
|
440
|
-
const result = super.next(...value);
|
|
441
|
-
if (result.done !== true) {
|
|
442
|
-
this._count--;
|
|
443
|
-
} else {
|
|
444
|
-
this._count = 0;
|
|
445
|
-
}
|
|
446
|
-
return result;
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
var IteratorTakeProxy = class extends IteratorCountProxyBase {
|
|
450
|
-
/**
|
|
451
|
-
* @inheritDoc
|
|
452
|
-
*/
|
|
453
|
-
next(...value) {
|
|
454
|
-
return !this.exhausted ? super.next(...value) : {
|
|
455
|
-
done: true,
|
|
456
|
-
value: void 0
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
var IteratorDropProxy = class extends IteratorCountProxyBase {
|
|
461
|
-
/**
|
|
462
|
-
* @inheritDoc
|
|
463
|
-
*/
|
|
464
|
-
next(...value) {
|
|
465
|
-
while (!this.exhausted) {
|
|
466
|
-
super.next(...value);
|
|
467
|
-
}
|
|
468
|
-
return super.next(...value);
|
|
129
|
+
var utilityResources = {
|
|
130
|
+
en: {
|
|
131
|
+
aidct_utility: localeStrings
|
|
132
|
+
},
|
|
133
|
+
fr: {
|
|
134
|
+
aidct_utility: localeStrings2
|
|
469
135
|
}
|
|
470
136
|
};
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
supported = process.env["NODE_ENV"] !== "test";
|
|
475
|
-
} catch (_e) {
|
|
476
|
-
supported = true;
|
|
477
|
-
}
|
|
478
|
-
if (supported) {
|
|
479
|
-
try {
|
|
480
|
-
Iterator.from([]);
|
|
481
|
-
} catch (_e) {
|
|
482
|
-
supported = false;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
return supported ? Iterator : {
|
|
486
|
-
/**
|
|
487
|
-
* @inheritDoc
|
|
488
|
-
*/
|
|
489
|
-
from(value) {
|
|
490
|
-
return value instanceof IteratorProxyBase ? value : new IteratorProxyObject(value);
|
|
491
|
-
}
|
|
492
|
-
};
|
|
137
|
+
var i18nextUtility = import_i18next.default.createInstance();
|
|
138
|
+
async function i18nUtilityInit(environment, debug = false) {
|
|
139
|
+
await (0, import_core.i18nCoreInit)(i18nextUtility, environment, debug, utilityNS, utilityResources);
|
|
493
140
|
}
|
|
494
|
-
var IteratorProxy = iteratorProxy();
|
|
495
141
|
|
|
496
142
|
// src/sequencer.ts
|
|
497
143
|
var Sequencer = class {
|
|
@@ -519,10 +165,6 @@ var Sequencer = class {
|
|
|
519
165
|
* Maximum value (inclusive).
|
|
520
166
|
*/
|
|
521
167
|
_maxValue;
|
|
522
|
-
/**
|
|
523
|
-
* Next value.
|
|
524
|
-
*/
|
|
525
|
-
_nextValue;
|
|
526
168
|
/**
|
|
527
169
|
* Constructor.
|
|
528
170
|
*
|
|
@@ -537,8 +179,7 @@ var Sequencer = class {
|
|
|
537
179
|
this._startValue = BigInt(startValue);
|
|
538
180
|
this._endValue = this._startValue + BigInt(count);
|
|
539
181
|
this._count = count;
|
|
540
|
-
|
|
541
|
-
if (ascending) {
|
|
182
|
+
if (count >= 0) {
|
|
542
183
|
this._nextDelta = 1n;
|
|
543
184
|
this._minValue = this._startValue;
|
|
544
185
|
this._maxValue = this._endValue - 1n;
|
|
@@ -547,7 +188,6 @@ var Sequencer = class {
|
|
|
547
188
|
this._minValue = this._endValue + 1n;
|
|
548
189
|
this._maxValue = this._startValue;
|
|
549
190
|
}
|
|
550
|
-
this._nextValue = this._startValue;
|
|
551
191
|
}
|
|
552
192
|
/**
|
|
553
193
|
* Get the start value (inclusive).
|
|
@@ -582,43 +222,27 @@ var Sequencer = class {
|
|
|
582
222
|
/**
|
|
583
223
|
* Iterable implementation.
|
|
584
224
|
*
|
|
585
|
-
* @
|
|
586
|
-
*
|
|
225
|
+
* @yields
|
|
226
|
+
* Next value in sequence.
|
|
587
227
|
*/
|
|
588
|
-
[Symbol.iterator]() {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Iterator implementation.
|
|
593
|
-
*
|
|
594
|
-
* @returns
|
|
595
|
-
* Iterator result. If iterator is exhausted, the value is absolute value of the count.
|
|
596
|
-
*/
|
|
597
|
-
next() {
|
|
598
|
-
const done = this._nextValue === this._endValue;
|
|
599
|
-
let result;
|
|
600
|
-
if (!done) {
|
|
601
|
-
result = {
|
|
602
|
-
value: this._nextValue
|
|
603
|
-
};
|
|
604
|
-
this._nextValue += this._nextDelta;
|
|
605
|
-
} else {
|
|
606
|
-
result = {
|
|
607
|
-
done: true,
|
|
608
|
-
value: Math.abs(this._count)
|
|
609
|
-
};
|
|
228
|
+
*[Symbol.iterator]() {
|
|
229
|
+
for (let value = this._startValue; value !== this._endValue; value += this._nextDelta) {
|
|
230
|
+
yield value;
|
|
610
231
|
}
|
|
611
|
-
return result;
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Reset the iterator.
|
|
615
|
-
*/
|
|
616
|
-
reset() {
|
|
617
|
-
this._nextValue = this._startValue;
|
|
618
232
|
}
|
|
619
233
|
};
|
|
620
234
|
|
|
621
235
|
// src/transformer.ts
|
|
236
|
+
function transformIterable(iterable, transformerCallback) {
|
|
237
|
+
return {
|
|
238
|
+
*[Symbol.iterator]() {
|
|
239
|
+
let index = 0;
|
|
240
|
+
for (const input of iterable) {
|
|
241
|
+
yield transformerCallback(input, index++);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
}
|
|
622
246
|
var Transformer = class _Transformer {
|
|
623
247
|
/**
|
|
624
248
|
* Transformers cache, mapping a domain to another map, which maps an optional tweak to a transformer.
|
|
@@ -637,8 +261,7 @@ var Transformer = class _Transformer {
|
|
|
637
261
|
constructor(domain) {
|
|
638
262
|
this._domain = BigInt(domain);
|
|
639
263
|
if (this._domain <= 0n) {
|
|
640
|
-
throw new RangeError(
|
|
641
|
-
ns: utilityNS,
|
|
264
|
+
throw new RangeError(i18nextUtility.t("Transformer.domainMustBeGreaterThanZero", {
|
|
642
265
|
domain
|
|
643
266
|
}));
|
|
644
267
|
}
|
|
@@ -687,14 +310,12 @@ var Transformer = class _Transformer {
|
|
|
687
310
|
*/
|
|
688
311
|
validate(value) {
|
|
689
312
|
if (value < 0n) {
|
|
690
|
-
throw new RangeError(
|
|
691
|
-
ns: utilityNS,
|
|
313
|
+
throw new RangeError(i18nextUtility.t("Transformer.valueMustBeGreaterThanOrEqualToZero", {
|
|
692
314
|
value
|
|
693
315
|
}));
|
|
694
316
|
}
|
|
695
317
|
if (value >= this.domain) {
|
|
696
|
-
throw new RangeError(
|
|
697
|
-
ns: utilityNS,
|
|
318
|
+
throw new RangeError(i18nextUtility.t("Transformer.valueMustBeLessThan", {
|
|
698
319
|
value,
|
|
699
320
|
domain: this.domain
|
|
700
321
|
}));
|
|
@@ -710,29 +331,35 @@ var Transformer = class _Transformer {
|
|
|
710
331
|
result = transformerCallback === void 0 ? transformedValue : transformerCallback(transformedValue, 0);
|
|
711
332
|
} else if (valueOrValues instanceof Sequencer) {
|
|
712
333
|
if (valueOrValues.minValue < 0n) {
|
|
713
|
-
throw new RangeError(
|
|
714
|
-
ns: utilityNS,
|
|
334
|
+
throw new RangeError(i18nextUtility.t("Transformer.minValueMustBeGreaterThanOrEqualToZero", {
|
|
715
335
|
minValue: valueOrValues.minValue
|
|
716
336
|
}));
|
|
717
337
|
}
|
|
718
338
|
if (valueOrValues.maxValue >= this.domain) {
|
|
719
|
-
throw new RangeError(
|
|
720
|
-
ns: utilityNS,
|
|
339
|
+
throw new RangeError(i18nextUtility.t("Transformer.maxValueMustBeLessThan", {
|
|
721
340
|
maxValue: valueOrValues.maxValue,
|
|
722
341
|
domain: this.domain
|
|
723
342
|
}));
|
|
724
343
|
}
|
|
725
|
-
|
|
344
|
+
if (transformerCallback === void 0) {
|
|
345
|
+
result = transformIterable(valueOrValues, (value) => this.doForward(value));
|
|
346
|
+
} else {
|
|
347
|
+
result = transformIterable(valueOrValues, (value, index) => transformerCallback(this.doForward(value), index));
|
|
348
|
+
}
|
|
726
349
|
} else {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
350
|
+
if (transformerCallback === void 0) {
|
|
351
|
+
result = transformIterable(valueOrValues, (value) => {
|
|
352
|
+
const valueN = BigInt(value);
|
|
353
|
+
this.validate(valueN);
|
|
354
|
+
return this.doForward(valueN);
|
|
355
|
+
});
|
|
356
|
+
} else {
|
|
357
|
+
result = transformIterable(valueOrValues, (value, index) => {
|
|
358
|
+
const valueN = BigInt(value);
|
|
359
|
+
this.validate(valueN);
|
|
360
|
+
return transformerCallback(this.doForward(valueN), index);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
736
363
|
}
|
|
737
364
|
return result;
|
|
738
365
|
}
|
|
@@ -828,8 +455,7 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
|
|
|
828
455
|
constructor(domain, tweak) {
|
|
829
456
|
super(domain);
|
|
830
457
|
if (tweak < 0n) {
|
|
831
|
-
throw new RangeError(
|
|
832
|
-
ns: utilityNS,
|
|
458
|
+
throw new RangeError(i18nextUtility.t("Transformer.tweakMustBeGreaterThanOrEqualToZero", {
|
|
833
459
|
tweak
|
|
834
460
|
}));
|
|
835
461
|
}
|
|
@@ -1020,7 +646,7 @@ var EncryptionTransformer = class _EncryptionTransformer extends Transformer {
|
|
|
1020
646
|
}
|
|
1021
647
|
};
|
|
1022
648
|
|
|
1023
|
-
// src/
|
|
649
|
+
// src/reg-exp.ts
|
|
1024
650
|
var RegExpValidator = class {
|
|
1025
651
|
/**
|
|
1026
652
|
* Regular expression.
|
|
@@ -1052,8 +678,7 @@ var RegExpValidator = class {
|
|
|
1052
678
|
* Error message.
|
|
1053
679
|
*/
|
|
1054
680
|
createErrorMessage(s) {
|
|
1055
|
-
return
|
|
1056
|
-
ns: utilityNS,
|
|
681
|
+
return i18nextUtility.t("RegExpValidator.stringDoesNotMatchPattern", {
|
|
1057
682
|
s
|
|
1058
683
|
});
|
|
1059
684
|
}
|
|
@@ -1109,9 +734,8 @@ var RecordValidator = class {
|
|
|
1109
734
|
* Record key.
|
|
1110
735
|
*/
|
|
1111
736
|
validate(key) {
|
|
1112
|
-
if (this.record
|
|
1113
|
-
throw new RangeError(
|
|
1114
|
-
ns: utilityNS,
|
|
737
|
+
if (!(key in this.record)) {
|
|
738
|
+
throw new RangeError(i18nextUtility.t("RecordValidator.typeNameKeyNotFound", {
|
|
1115
739
|
typeName: this.typeName,
|
|
1116
740
|
key
|
|
1117
741
|
}));
|
|
@@ -1119,7 +743,7 @@ var RecordValidator = class {
|
|
|
1119
743
|
}
|
|
1120
744
|
};
|
|
1121
745
|
|
|
1122
|
-
// src/
|
|
746
|
+
// src/character-set.ts
|
|
1123
747
|
var Exclusion = /* @__PURE__ */ ((Exclusion2) => {
|
|
1124
748
|
Exclusion2[Exclusion2["None"] = 0] = "None";
|
|
1125
749
|
Exclusion2[Exclusion2["FirstZero"] = 1] = "FirstZero";
|
|
@@ -1138,9 +762,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
|
|
|
1138
762
|
* Error message.
|
|
1139
763
|
*/
|
|
1140
764
|
createErrorMessage(_s) {
|
|
1141
|
-
return
|
|
1142
|
-
ns: utilityNS
|
|
1143
|
-
});
|
|
765
|
+
return i18nextUtility.t("CharacterSetValidator.stringMustNotBeAllNumeric");
|
|
1144
766
|
}
|
|
1145
767
|
}(/\D/);
|
|
1146
768
|
/**
|
|
@@ -1250,8 +872,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
|
|
|
1250
872
|
*/
|
|
1251
873
|
validateExclusion(exclusion) {
|
|
1252
874
|
if (exclusion !== 0 /* None */ && !this._exclusionSupport.includes(exclusion)) {
|
|
1253
|
-
throw new RangeError(
|
|
1254
|
-
ns: utilityNS,
|
|
875
|
+
throw new RangeError(i18nextUtility.t("CharacterSetValidator.exclusionNotSupported", {
|
|
1255
876
|
exclusion
|
|
1256
877
|
}));
|
|
1257
878
|
}
|
|
@@ -1273,15 +894,13 @@ var CharacterSetValidator = class _CharacterSetValidator {
|
|
|
1273
894
|
if (minimumLength !== void 0 && length < minimumLength) {
|
|
1274
895
|
let errorMessage;
|
|
1275
896
|
if (maximumLength !== void 0 && maximumLength === minimumLength) {
|
|
1276
|
-
errorMessage =
|
|
1277
|
-
ns: utilityNS,
|
|
897
|
+
errorMessage = i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeEqualTo", {
|
|
1278
898
|
component: _CharacterSetValidator.componentToString(validation?.component),
|
|
1279
899
|
length,
|
|
1280
900
|
exactLength: minimumLength
|
|
1281
901
|
});
|
|
1282
902
|
} else {
|
|
1283
|
-
errorMessage =
|
|
1284
|
-
ns: utilityNS,
|
|
903
|
+
errorMessage = i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeGreaterThanOrEqualTo", {
|
|
1285
904
|
component: _CharacterSetValidator.componentToString(validation?.component),
|
|
1286
905
|
length,
|
|
1287
906
|
minimumLength
|
|
@@ -1290,8 +909,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
|
|
|
1290
909
|
throw new RangeError(errorMessage);
|
|
1291
910
|
}
|
|
1292
911
|
if (maximumLength !== void 0 && length > maximumLength) {
|
|
1293
|
-
throw new RangeError(
|
|
1294
|
-
ns: utilityNS,
|
|
912
|
+
throw new RangeError(i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.lengthMustBeLessThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeLessThanOrEqualTo", {
|
|
1295
913
|
component: _CharacterSetValidator.componentToString(validation?.component),
|
|
1296
914
|
length,
|
|
1297
915
|
maximumLength
|
|
@@ -1299,8 +917,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
|
|
|
1299
917
|
}
|
|
1300
918
|
const index = this.characterIndexes(s).findIndex((characterIndex) => characterIndex === void 0);
|
|
1301
919
|
if (index !== -1) {
|
|
1302
|
-
throw new RangeError(
|
|
1303
|
-
ns: utilityNS,
|
|
920
|
+
throw new RangeError(i18nextUtility.t(validation?.component === void 0 ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
|
|
1304
921
|
component: _CharacterSetValidator.componentToString(validation?.component),
|
|
1305
922
|
c: s.charAt(index),
|
|
1306
923
|
position: index + (validation?.positionOffset ?? 0) + 1
|
|
@@ -1313,8 +930,7 @@ var CharacterSetValidator = class _CharacterSetValidator {
|
|
|
1313
930
|
break;
|
|
1314
931
|
case 1 /* FirstZero */:
|
|
1315
932
|
if (s.startsWith("0")) {
|
|
1316
|
-
throw new RangeError(
|
|
1317
|
-
ns: utilityNS,
|
|
933
|
+
throw new RangeError(i18nextUtility.t(validation.component === void 0 ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
|
|
1318
934
|
component: _CharacterSetValidator.componentToString(validation.component),
|
|
1319
935
|
c: "0",
|
|
1320
936
|
position: (validation.positionOffset ?? 0) + 1
|
|
@@ -1401,9 +1017,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
1401
1017
|
exclusionDomains[0 /* None */] = exclusionNoneDomains;
|
|
1402
1018
|
if (exclusionSupport.includes(1 /* FirstZero */)) {
|
|
1403
1019
|
if (characterSet[0] !== "0") {
|
|
1404
|
-
throw new RangeError(
|
|
1405
|
-
ns: utilityNS
|
|
1406
|
-
}));
|
|
1020
|
+
throw new RangeError(i18nextUtility.t("CharacterSetValidator.firstZeroFirstCharacter"));
|
|
1407
1021
|
}
|
|
1408
1022
|
const exclusionFirstZeroDomains = new Array(_CharacterSetCreator.MAXIMUM_STRING_LENGTH + 1);
|
|
1409
1023
|
exclusionFirstZeroDomains[0] = 0n;
|
|
@@ -1417,9 +1031,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
1417
1031
|
let expectedNumberIndex = numberIndexes2[0];
|
|
1418
1032
|
for (const numberIndex of numberIndexes2) {
|
|
1419
1033
|
if (numberIndex === void 0 || numberIndex !== expectedNumberIndex) {
|
|
1420
|
-
throw new RangeError(
|
|
1421
|
-
ns: utilityNS
|
|
1422
|
-
}));
|
|
1034
|
+
throw new RangeError(i18nextUtility.t("CharacterSetValidator.allNumericAllNumericCharacters"));
|
|
1423
1035
|
}
|
|
1424
1036
|
expectedNumberIndex = numberIndex + 1;
|
|
1425
1037
|
}
|
|
@@ -1474,9 +1086,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
1474
1086
|
let shift;
|
|
1475
1087
|
if (length === 0) {
|
|
1476
1088
|
if (!shiftForward && value < 10n) {
|
|
1477
|
-
throw new RangeError(
|
|
1478
|
-
ns: utilityNS
|
|
1479
|
-
}));
|
|
1089
|
+
throw new RangeError(i18nextUtility.t("CharacterSetValidator.stringMustNotBeAllNumeric"));
|
|
1480
1090
|
}
|
|
1481
1091
|
shift = 10n;
|
|
1482
1092
|
} else {
|
|
@@ -1500,15 +1110,13 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
1500
1110
|
*/
|
|
1501
1111
|
validateLength(length) {
|
|
1502
1112
|
if (length < 0) {
|
|
1503
|
-
throw new RangeError(
|
|
1504
|
-
ns: utilityNS,
|
|
1113
|
+
throw new RangeError(i18nextUtility.t("CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo", {
|
|
1505
1114
|
length,
|
|
1506
1115
|
minimumLength: 0
|
|
1507
1116
|
}));
|
|
1508
1117
|
}
|
|
1509
1118
|
if (length > _CharacterSetCreator.MAXIMUM_STRING_LENGTH) {
|
|
1510
|
-
throw new RangeError(
|
|
1511
|
-
ns: utilityNS,
|
|
1119
|
+
throw new RangeError(i18nextUtility.t("CharacterSetValidator.lengthMustBeLessThanOrEqualTo", {
|
|
1512
1120
|
length,
|
|
1513
1121
|
maximumLength: _CharacterSetCreator.MAXIMUM_STRING_LENGTH
|
|
1514
1122
|
}));
|
|
@@ -1582,8 +1190,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
1582
1190
|
const characterSetSizeN = BigInt(this.characterSetSize);
|
|
1583
1191
|
let value = this.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
|
|
1584
1192
|
if (characterIndex === void 0) {
|
|
1585
|
-
throw new RangeError(
|
|
1586
|
-
ns: utilityNS,
|
|
1193
|
+
throw new RangeError(i18nextUtility.t("CharacterSetValidator.invalidCharacterAtPosition", {
|
|
1587
1194
|
c: s.charAt(index),
|
|
1588
1195
|
position: index + 1
|
|
1589
1196
|
}));
|
|
@@ -1591,8 +1198,7 @@ var CharacterSetCreator = class _CharacterSetCreator extends CharacterSetValidat
|
|
|
1591
1198
|
let value2;
|
|
1592
1199
|
if (index === 0 && exclusion === 1 /* FirstZero */) {
|
|
1593
1200
|
if (characterIndex === 0) {
|
|
1594
|
-
throw new RangeError(
|
|
1595
|
-
ns: utilityNS,
|
|
1201
|
+
throw new RangeError(i18nextUtility.t("CharacterSetValidator.invalidCharacterAtPosition", {
|
|
1596
1202
|
c: "0",
|
|
1597
1203
|
position: 1
|
|
1598
1204
|
}));
|
|
@@ -1718,11 +1324,14 @@ var ALPHANUMERIC_CREATOR = new CharacterSetCreator([
|
|
|
1718
1324
|
Exclusion,
|
|
1719
1325
|
HEXADECIMAL_CREATOR,
|
|
1720
1326
|
IdentityTransformer,
|
|
1721
|
-
IteratorProxy,
|
|
1722
1327
|
NUMERIC_CREATOR,
|
|
1723
1328
|
RecordValidator,
|
|
1724
1329
|
RegExpValidator,
|
|
1725
1330
|
Sequencer,
|
|
1726
1331
|
Transformer,
|
|
1727
|
-
|
|
1332
|
+
i18nUtilityInit,
|
|
1333
|
+
i18nextUtility,
|
|
1334
|
+
transformIterable,
|
|
1335
|
+
utilityNS,
|
|
1336
|
+
utilityResources
|
|
1728
1337
|
});
|