@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.d.ts CHANGED
@@ -1,63 +1,569 @@
1
- declare const utilityNS = "aidct_utility";
1
+ import { $NormalizeIntoArray, $Dictionary } from './typescript/helpers.js';
2
+ import { DefaultNamespace, FlatNamespace, InitOptions, Namespace, FormatFunction, Resource, TOptions, InterpolationOptions, ResourceLanguage, ResourceKey } from './typescript/options.js';
3
+ import { TFunction, KeyPrefix } from './typescript/t.js';
4
+ import { I18NEnvironment } from '@aidc-toolkit/core';
5
+ import { Resource as Resource$1 } from 'i18next';
6
+
7
+ // Internal Helpers
8
+
9
+
10
+ interface Interpolator {
11
+ init(options: InterpolationOptions, reset: boolean): undefined;
12
+ reset(): undefined;
13
+ resetRegExp(): undefined;
14
+ interpolate(str: string, data: object, lng: string, options: InterpolationOptions): string;
15
+ nest(str: string, fc: (...args: any[]) => any, options: InterpolationOptions): string;
16
+ }
17
+
18
+ declare class ResourceStore {
19
+ constructor(data: Resource, options: InitOptions);
20
+
21
+ public data: Resource;
22
+
23
+ public options: InitOptions;
24
+
25
+ /**
26
+ * Gets fired when resources got added or removed
27
+ */
28
+ on(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): void;
29
+
30
+ /**
31
+ * Remove event listener
32
+ * removes all callback when callback not specified
33
+ */
34
+ off(event: 'added' | 'removed', callback?: (lng: string, ns: string) => void): void;
35
+ }
36
+
37
+ interface Formatter {
38
+ init(services: Services, i18nextOptions: InitOptions): void;
39
+ add(name: string, fc: (value: any, lng: string | undefined, options: any) => string): void;
40
+ addCached(
41
+ name: string,
42
+ fc: (lng: string | undefined, options: any) => (value: any) => string,
43
+ ): void;
44
+ format: FormatFunction;
45
+ }
46
+
47
+ interface Services {
48
+ backendConnector: any;
49
+ i18nFormat: any;
50
+ interpolator: Interpolator;
51
+ languageDetector: any;
52
+ languageUtils: any;
53
+ logger: any;
54
+ pluralResolver: any;
55
+ resourceStore: ResourceStore;
56
+ formatter?: Formatter;
57
+ }
58
+
59
+ type ModuleType =
60
+ | 'backend'
61
+ | 'logger'
62
+ | 'languageDetector'
63
+ | 'postProcessor'
64
+ | 'i18nFormat'
65
+ | 'formatter'
66
+ | '3rdParty';
67
+
68
+ interface Module {
69
+ type: ModuleType;
70
+ }
71
+
72
+ type CallbackError = Error | string | null | undefined;
73
+ type ReadCallback = (
74
+ err: CallbackError,
75
+ data: ResourceKey | boolean | null | undefined,
76
+ ) => void;
77
+ type MultiReadCallback = (err: CallbackError, data: Resource | null | undefined) => void;
2
78
 
3
79
  /**
4
- * Transformer input, one of:
5
- *
6
- * - T (primitive type)
7
- * - Iterable<T>
8
- *
9
- * @template T
10
- * Primitive type.
80
+ * Used to load data for i18next.
81
+ * Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
82
+ * For singleton set property `type` to `'backend'` For a prototype constructor set static property.
11
83
  */
12
- type TransformerInput<T extends string | number | bigint | boolean> = T | Iterable<T>;
84
+ interface BackendModule<Options = object> extends Module {
85
+ type: 'backend';
86
+ init(services: Services, backendOptions: Options, i18nextOptions: InitOptions): void;
87
+ read(language: string, namespace: string, callback: ReadCallback): void;
88
+ /** Save the missing translation */
89
+ create?(
90
+ languages: readonly string[],
91
+ namespace: string,
92
+ key: string,
93
+ fallbackValue: string,
94
+ ): void;
95
+ /** Load multiple languages and namespaces. For backends supporting multiple resources loading */
96
+ readMulti?(
97
+ languages: readonly string[],
98
+ namespaces: readonly string[],
99
+ callback: MultiReadCallback,
100
+ ): void;
101
+ /** Store the translation. For backends acting as cache layer */
102
+ save?(language: string, namespace: string, data: ResourceLanguage): void;
103
+ }
104
+
13
105
  /**
14
- * Transformer callback, used to convert transformed value to its final value.
15
- *
16
- * @template TInput
17
- * Type of input to callback.
18
- *
19
- * @template TOutput
20
- * Type of output to callback.
21
- *
22
- * @param input
23
- * Input value.
24
- *
25
- * @param index
26
- * Index in sequence (0 for single transformation).
27
- *
28
- * @returns
29
- * Output value.
106
+ * Used to detect language in user land.
107
+ * Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
108
+ * For singleton set property `type` to `'languageDetector'` For a prototype constructor set static property.
30
109
  */
31
- type TransformerCallback<TInput, TOutput> = (input: TInput, index: number) => TOutput;
110
+ interface LanguageDetectorModule extends Module {
111
+ type: 'languageDetector';
112
+ init?(services: Services, detectorOptions: object, i18nextOptions: InitOptions): void;
113
+ /** Must return detected language */
114
+ detect(): string | readonly string[] | undefined;
115
+ cacheUserLanguage?(lng: string): void;
116
+ }
117
+
32
118
  /**
33
- * Transformer output, based on transformer input:
34
- *
35
- * - If type T is primitive type, result is type U.
36
- * - If type T is Iterable type, result is type IterableIterator<U>.
37
- *
38
- * @template T
39
- * Transformer input type.
40
- *
41
- * @template U
42
- * Output base type.
119
+ * Used to detect language in user land.
120
+ * Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
121
+ * For singleton set property `type` to `'languageDetector'` For a prototype constructor set static property.
122
+ */
123
+ interface LanguageDetectorAsyncModule extends Module {
124
+ type: 'languageDetector';
125
+ /** Set to true to enable async detection */
126
+ async: true;
127
+ init?(services: Services, detectorOptions: object, i18nextOptions: InitOptions): void;
128
+ /** Must call callback passing detected language or return a Promise */
129
+ detect(
130
+ callback: (lng: string | readonly string[] | undefined) => void | undefined,
131
+ ): void | Promise<string | readonly string[] | undefined>;
132
+ cacheUserLanguage?(lng: string): void | Promise<void>;
133
+ }
134
+
135
+ /**
136
+ * Override the built-in console logger.
137
+ * Do not need to be a prototype function.
43
138
  */
44
- type TransformerOutput<T extends TransformerInput<string | number | bigint | boolean>, U> = T extends (T extends TransformerInput<infer V> ? V : never) ? U : IterableIterator<U>;
139
+ interface LoggerModule extends Module {
140
+ type: 'logger';
141
+ log(...args: any[]): void;
142
+ warn(...args: any[]): void;
143
+ error(...args: any[]): void;
144
+ }
145
+
146
+ interface I18nFormatModule extends Module {
147
+ type: 'i18nFormat';
148
+ }
149
+
150
+ interface FormatterModule extends Module, Formatter {
151
+ type: 'formatter';
152
+ }
153
+
154
+ interface ThirdPartyModule extends Module {
155
+ type: '3rdParty';
156
+ init(i18next: i18n): void;
157
+ }
158
+
159
+ interface Modules {
160
+ backend?: BackendModule;
161
+ logger?: LoggerModule;
162
+ languageDetector?: LanguageDetectorModule | LanguageDetectorAsyncModule;
163
+ i18nFormat?: I18nFormatModule;
164
+ formatter?: FormatterModule;
165
+ external: ThirdPartyModule[];
166
+ }
167
+
168
+ // helper to identify class https://stackoverflow.com/a/45983481/2363935
169
+ interface Newable<T> {
170
+ new (...args: any[]): T;
171
+ }
172
+ interface NewableModule<T extends Module> extends Newable<T> {
173
+ type: T['type'];
174
+ }
175
+
176
+ type Callback = (error: any, t: TFunction) => void;
177
+
178
+ /**
179
+ * Uses similar args as the t function and returns true if a key exists.
180
+ */
181
+ interface ExistsFunction<
182
+ TKeys extends string = string,
183
+ TInterpolationMap extends object = $Dictionary,
184
+ > {
185
+ (key: TKeys | TKeys[], options?: TOptions<TInterpolationMap>): boolean;
186
+ }
187
+
188
+ interface CloneOptions extends InitOptions {
189
+ /**
190
+ * Will create a new instance of the resource store and import the existing translation resources.
191
+ * This way it will not shared the resource store instance.
192
+ * @default false
193
+ */
194
+ forkResourceStore?: boolean;
195
+ }
196
+
197
+ interface CustomInstanceExtensions {}
198
+
199
+ // Used just here to exclude `DefaultNamespace` which can be both string or array from `FlatNamespace`
200
+ // in TFunction declaration below.
201
+ // Due to this only very special usage I'm not moving this inside helpers.
202
+ type InferArrayValuesElseReturnType<T> = T extends (infer A)[] ? A : T;
203
+
204
+ // eslint-disable-next-line @typescript-eslint/naming-convention
205
+ interface i18n extends CustomInstanceExtensions {
206
+ // Expose parameterized t in the i18next interface hierarchy
207
+ t: TFunction<
208
+ [
209
+ ...$NormalizeIntoArray<DefaultNamespace>,
210
+ ...Exclude<FlatNamespace, InferArrayValuesElseReturnType<DefaultNamespace>>[],
211
+ ]
212
+ >;
213
+
214
+ /**
215
+ * The default of the i18next module is an i18next instance ready to be initialized by calling init.
216
+ * You can create additional instances using the createInstance function.
217
+ *
218
+ * @param options - Initial options.
219
+ * @param callback - will be called after all translations were loaded or with an error when failed (in case of using a backend).
220
+ */
221
+ init(callback?: Callback): Promise<TFunction>;
222
+ init<T>(options: InitOptions<T>, callback?: Callback): Promise<TFunction>;
223
+
224
+ loadResources(callback?: (err: any) => void): void;
225
+
226
+ /**
227
+ * The use function is there to load additional plugins to i18next.
228
+ * For available module see the plugins page and don't forget to read the documentation of the plugin.
229
+ *
230
+ * @param module Accepts a class or object
231
+ */
232
+ use<T extends Module>(module: T | NewableModule<T> | Newable<T>): this;
233
+
234
+ /**
235
+ * List of modules used
236
+ */
237
+ modules: Modules;
238
+
239
+ /**
240
+ * Internal container for all used plugins and implementation details like languageUtils, pluralResolvers, etc.
241
+ */
242
+ services: Services;
243
+
244
+ /**
245
+ * Internal container for translation resources
246
+ */
247
+ store: ResourceStore;
248
+
249
+ /**
250
+ * Uses similar args as the t function and returns true if a key exists.
251
+ */
252
+ exists: ExistsFunction;
253
+
254
+ /**
255
+ * Returns a resource data by language.
256
+ */
257
+ getDataByLanguage(lng: string): { [key: string]: { [key: string]: string } } | undefined;
258
+
259
+ /**
260
+ * Returns a t function that defaults to given language or namespace.
261
+ * Both params could be arrays of languages or namespaces and will be treated as fallbacks in that case.
262
+ * On the returned function you can like in the t function override the languages or namespaces by passing them in options or by prepending namespace.
263
+ *
264
+ * Accepts optional keyPrefix that will be automatically applied to returned t function.
265
+ */
266
+ getFixedT<
267
+ Ns extends Namespace | null = DefaultNamespace,
268
+ TKPrefix extends KeyPrefix<ActualNs> = undefined,
269
+ ActualNs extends Namespace = Ns extends null ? DefaultNamespace : Ns,
270
+ >(
271
+ ...args:
272
+ | [lng: string | readonly string[], ns?: Ns, keyPrefix?: TKPrefix]
273
+ | [lng: null, ns: Ns, keyPrefix?: TKPrefix]
274
+ ): TFunction<ActualNs, TKPrefix>;
275
+
276
+ /**
277
+ * Changes the language. The callback will be called as soon translations were loaded or an error occurs while loading.
278
+ * HINT: For easy testing - setting lng to 'cimode' will set t function to always return the key.
279
+ */
280
+ changeLanguage(lng?: string, callback?: Callback): Promise<TFunction>;
281
+
282
+ /**
283
+ * Is set to the current detected or set language.
284
+ * If you need the primary used language depending on your configuration (supportedLngs, load) you will prefer using i18next.languages[0].
285
+ */
286
+ language: string;
287
+
288
+ /**
289
+ * Is set to an array of language-codes that will be used it order to lookup the translation value.
290
+ */
291
+ languages: readonly string[];
292
+
293
+ /**
294
+ * Is set to the current resolved language.
295
+ * It can be used as primary used language, for example in a language switcher.
296
+ */
297
+ resolvedLanguage?: string;
45
298
 
299
+ /**
300
+ * Checks if namespace has loaded yet.
301
+ * i.e. used by react-i18next
302
+ */
303
+ hasLoadedNamespace(
304
+ ns: string | readonly string[],
305
+ options?: {
306
+ lng?: string | readonly string[];
307
+ fallbackLng?: InitOptions['fallbackLng'];
308
+ /**
309
+ * if `undefined` is returned default checks are performed.
310
+ */
311
+ precheck?: (
312
+ i18n: i18n,
313
+ /**
314
+ * Check if the language namespace provided are not in loading status:
315
+ * returns `true` if load is completed successfully or with an error.
316
+ */
317
+ loadNotPending: (
318
+ lng: string | readonly string[],
319
+ ns: string | readonly string[],
320
+ ) => boolean,
321
+ ) => boolean | undefined;
322
+ },
323
+ ): boolean;
324
+
325
+ /**
326
+ * Loads additional namespaces not defined in init options.
327
+ */
328
+ loadNamespaces(ns: string | readonly string[], callback?: Callback): Promise<void>;
329
+
330
+ /**
331
+ * Loads additional languages not defined in init options (preload).
332
+ */
333
+ loadLanguages(lngs: string | readonly string[], callback?: Callback): Promise<void>;
334
+
335
+ /**
336
+ * Reloads resources on given state. Optionally you can pass an array of languages and namespaces as params if you don't want to reload all.
337
+ */
338
+ reloadResources(
339
+ lngs?: string | readonly string[],
340
+ ns?: string | readonly string[],
341
+ callback?: () => void,
342
+ ): Promise<void>;
343
+ reloadResources(lngs: null, ns: string | readonly string[], callback?: () => void): Promise<void>;
344
+
345
+ /**
346
+ * Changes the default namespace.
347
+ */
348
+ setDefaultNamespace(ns: string | readonly string[]): void;
349
+
350
+ /**
351
+ * Returns rtl or ltr depending on languages read direction.
352
+ */
353
+ dir(lng?: string): 'ltr' | 'rtl';
354
+
355
+ /**
356
+ * Exposes interpolation.format function added on init.
357
+ */
358
+ format: FormatFunction;
359
+
360
+ /**
361
+ * Will return a new i18next instance.
362
+ * Please read the options page for details on configuration options.
363
+ * Providing a callback will automatically call init.
364
+ * The callback will be called after all translations were loaded or with an error when failed (in case of using a backend).
365
+ */
366
+ createInstance(options?: InitOptions, callback?: Callback): i18n;
367
+
368
+ /**
369
+ * Creates a clone of the current instance. Shares store, plugins and initial configuration.
370
+ * Can be used to create an instance sharing storage but being independent on set language or namespaces.
371
+ */
372
+ cloneInstance(options?: CloneOptions, callback?: Callback): i18n;
373
+
374
+ /**
375
+ * Gets fired after initialization.
376
+ */
377
+ on(event: 'initialized', callback: (options: InitOptions) => void): void;
378
+
379
+ /**
380
+ * Gets fired on loaded resources.
381
+ */
382
+ on(
383
+ event: 'loaded',
384
+ callback: (loaded: { [language: string]: { [namespace: string]: boolean } }) => void,
385
+ ): void;
386
+
387
+ /**
388
+ * Gets fired if loading resources failed.
389
+ */
390
+ on(event: 'failedLoading', callback: (lng: string, ns: string, msg: string) => void): void;
391
+
392
+ /**
393
+ * Gets fired on accessing a key not existing.
394
+ */
395
+ on(
396
+ event: 'missingKey',
397
+ callback: (lngs: readonly string[], namespace: string, key: string, res: string) => void,
398
+ ): void;
399
+
400
+ /**
401
+ * Gets fired when resources got added or removed.
402
+ */
403
+ on(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): void;
404
+
405
+ /**
406
+ * Gets fired when changeLanguage got called.
407
+ */
408
+ on(event: 'languageChanged', callback: (lng: string) => void): void;
409
+
410
+ /**
411
+ * Event listener
412
+ */
413
+ on(event: string, listener: (...args: any[]) => void): void;
414
+
415
+ /**
416
+ * Remove event listener
417
+ * removes all callback when callback not specified
418
+ */
419
+ off(event: string, listener?: (...args: any[]) => void): void;
420
+
421
+ /**
422
+ * Gets one value by given key.
423
+ */
424
+ getResource(
425
+ lng: string,
426
+ ns: string,
427
+ key: string,
428
+ options?: Pick<InitOptions, 'keySeparator' | 'ignoreJSONStructure'>,
429
+ ): any;
430
+
431
+ /**
432
+ * Adds one key/value.
433
+ */
434
+ addResource(
435
+ lng: string,
436
+ ns: string,
437
+ key: string,
438
+ value: string,
439
+ options?: { keySeparator?: string; silent?: boolean },
440
+ ): i18n;
441
+
442
+ /**
443
+ * Adds multiple key/values.
444
+ */
445
+ addResources(lng: string, ns: string, resources: any): i18n;
446
+
447
+ /**
448
+ * Adds a complete bundle.
449
+ * Setting deep param to true will extend existing translations in that file.
450
+ * Setting overwrite to true it will overwrite existing translations in that file.
451
+ */
452
+ addResourceBundle(
453
+ lng: string,
454
+ ns: string,
455
+ resources: any,
456
+ deep?: boolean,
457
+ overwrite?: boolean,
458
+ ): i18n;
459
+
460
+ /**
461
+ * Checks if a resource bundle exists.
462
+ */
463
+ hasResourceBundle(lng: string, ns: string): boolean;
464
+
465
+ /**
466
+ * Returns a resource bundle.
467
+ */
468
+ getResourceBundle(lng: string, ns: string): any;
469
+
470
+ /**
471
+ * Removes an existing bundle.
472
+ */
473
+ removeResourceBundle(lng: string, ns: string): i18n;
474
+
475
+ /**
476
+ * Current options
477
+ */
478
+ options: InitOptions;
479
+
480
+ /**
481
+ * Is initialized
482
+ */
483
+ isInitialized: boolean;
484
+
485
+ /**
486
+ * Is initializing
487
+ */
488
+ isInitializing: boolean;
489
+
490
+ /**
491
+ * Store was initialized
492
+ */
493
+ initializedStoreOnce: boolean;
494
+
495
+ /**
496
+ * Language was initialized
497
+ */
498
+ initializedLanguageOnce: boolean;
499
+
500
+ /**
501
+ * Emit event
502
+ */
503
+ emit(eventName: string, ...args: any[]): void;
504
+ }
505
+
506
+ declare const localeStrings: {
507
+ readonly Transformer: {
508
+ readonly domainMustBeGreaterThanZero: "Domain {{domain}} must be greater than 0";
509
+ readonly tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak}} must be greater than or equal to 0";
510
+ readonly valueMustBeGreaterThanOrEqualToZero: "Value {{value}} must be greater than or equal to 0";
511
+ readonly valueMustBeLessThan: "Value {{value}} must be less than {{domain}}";
512
+ readonly minValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minValue}} must be greater than or equal to 0";
513
+ readonly maxValueMustBeLessThan: "Maximum value {{maxValue}} must be less than {{domain}}";
514
+ };
515
+ readonly RegExpValidator: {
516
+ readonly stringDoesNotMatchPattern: "String {{s}} does not match pattern";
517
+ };
518
+ readonly CharacterSetValidator: {
519
+ readonly firstZeroFirstCharacter: "Character set must support zero as first character";
520
+ readonly allNumericAllNumericCharacters: "Character set must support all numeric characters in sequence";
521
+ readonly stringMustNotBeAllNumeric: "String must not be all numeric";
522
+ readonly lengthMustBeGreaterThanOrEqualTo: "Length {{length}} must be greater than or equal to {{minimumLength}}";
523
+ readonly lengthMustBeLessThanOrEqualTo: "Length {{length}} must be less than or equal to {{maximumLength}}";
524
+ readonly lengthMustBeEqualTo: "Length {{length}} must be equal to {{exactLength}}";
525
+ readonly lengthOfComponentMustBeGreaterThanOrEqualTo: "Length {{length}} of {{component}} must be greater than or equal to {{minimumLength}}";
526
+ readonly lengthOfComponentMustBeLessThanOrEqualTo: "Length {{length}} of {{component}} must be less than or equal to {{maximumLength}}";
527
+ readonly lengthOfComponentMustBeEqualTo: "Length {{length}} of {{component}} must be equal to {{exactLength}}";
528
+ readonly invalidCharacterAtPosition: "Invalid character '{{c}}' at position {{position}}";
529
+ readonly invalidCharacterAtPositionOfComponent: "Invalid character '{{c}}' at position {{position}} of {{component}}";
530
+ readonly exclusionNotSupported: "Exclusion value of {{exclusion}} is not supported";
531
+ readonly invalidTweakWithAllNumericExclusion: "Tweak must not be used with all-numeric exclusion";
532
+ readonly endSequenceValueMustBeLessThanOrEqualTo: "End sequence value (start sequence value + count - 1) must be less than {{domain}}";
533
+ };
534
+ readonly RecordValidator: {
535
+ readonly typeNameKeyNotFound: "{{typeName}} \"{{key}}\" not found";
536
+ };
537
+ };
538
+
539
+ declare const utilityNS = "aidct_utility";
46
540
  /**
47
- * Iterator proxy. In environments where
48
- * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helpers |
49
- * iterator helpers} are supported, this references the {@linkcode Iterator} variable directly. Otherwise, it references
50
- * an implementation of "from" that uses an internally-defined iterator proxy object.
541
+ * Locale strings type is extracted from the English locale strings object.
542
+ */
543
+ type UtilityLocaleStrings = typeof localeStrings;
544
+ /**
545
+ * Utility resources.
546
+ */
547
+ declare const utilityResources: Resource$1;
548
+ declare const i18nextUtility: i18n;
549
+ /**
550
+ * Initialize internationalization.
551
+ *
552
+ * @param environment
553
+ * Environment in which the application is running.
554
+ *
555
+ * @param debug
556
+ * Debug setting.
51
557
  *
52
- * Client applications should **not** rely on long-term availability of this variable as it will be removed once there
53
- * is widespread support for iterator helpers.
558
+ * @returns
559
+ * Void promise.
54
560
  */
55
- declare const IteratorProxy: Pick<IteratorConstructor, "from">;
561
+ declare function i18nUtilityInit(environment: I18NEnvironment, debug?: boolean): Promise<void>;
56
562
 
57
563
  /**
58
- * Sequencer. Defines an ascending or descending sequence of big integers implemented as an iterable iterator.
564
+ * Sequencer. Defines an ascending or descending sequence of big integers implemented as an iterable.
59
565
  */
60
- declare class Sequencer implements Iterable<bigint>, IterableIterator<bigint> {
566
+ declare class Sequencer implements Iterable<bigint> {
61
567
  /**
62
568
  * Start value (inclusive).
63
569
  */
@@ -82,10 +588,6 @@ declare class Sequencer implements Iterable<bigint>, IterableIterator<bigint> {
82
588
  * Maximum value (inclusive).
83
589
  */
84
590
  private readonly _maxValue;
85
- /**
86
- * Next value.
87
- */
88
- private _nextValue;
89
591
  /**
90
592
  * Constructor.
91
593
  *
@@ -120,23 +622,67 @@ declare class Sequencer implements Iterable<bigint>, IterableIterator<bigint> {
120
622
  /**
121
623
  * Iterable implementation.
122
624
  *
123
- * @returns
124
- * this
125
- */
126
- [Symbol.iterator](): this;
127
- /**
128
- * Iterator implementation.
129
- *
130
- * @returns
131
- * Iterator result. If iterator is exhausted, the value is absolute value of the count.
625
+ * @yields
626
+ * Next value in sequence.
132
627
  */
133
- next(): IteratorResult<bigint, number>;
134
- /**
135
- * Reset the iterator.
136
- */
137
- reset(): void;
628
+ [Symbol.iterator](): Generator<bigint>;
138
629
  }
139
630
 
631
+ /**
632
+ * Transformer input, one of:
633
+ *
634
+ * - T (primitive type)
635
+ * - Iterable<T>
636
+ *
637
+ * @template T
638
+ * Primitive type.
639
+ */
640
+ type TransformerInput<T extends string | number | bigint | boolean> = T | Iterable<T>;
641
+ /**
642
+ * Transformer callback, used to convert transformed value to its final value.
643
+ *
644
+ * @template TInput
645
+ * Type of input to callback.
646
+ *
647
+ * @template TOutput
648
+ * Type of output to callback.
649
+ *
650
+ * @param input
651
+ * Input value.
652
+ *
653
+ * @param index
654
+ * Index in sequence (0 for single transformation).
655
+ *
656
+ * @returns
657
+ * Output value.
658
+ */
659
+ type TransformerCallback<TInput, TOutput> = (input: TInput, index: number) => TOutput;
660
+ /**
661
+ * Transformer output, based on transformer input:
662
+ *
663
+ * - If type T is primitive, result is type TOutput.
664
+ * - If type T is Iterable, result is type Iterable<TOutput>.
665
+ *
666
+ * @template T
667
+ * Transformer input type.
668
+ *
669
+ * @template TOutput
670
+ * Output base type.
671
+ */
672
+ type TransformerOutput<T extends TransformerInput<string | number | bigint | boolean>, TOutput> = T extends (T extends TransformerInput<infer TInput> ? TInput : never) ? TOutput : Iterable<TOutput>;
673
+ /**
674
+ * Transform an iterable by applying a transformer callback to each entry.
675
+ *
676
+ * @param iterable
677
+ * Input iterable.
678
+ *
679
+ * @param transformerCallback
680
+ * Callback to transform input value to output value.
681
+ *
682
+ * @returns
683
+ * Output iterable.
684
+ */
685
+ declare function transformIterable<TInput, TOutput>(iterable: Iterable<TInput>, transformerCallback: TransformerCallback<TInput, TOutput>): Iterable<TOutput>;
140
686
  /**
141
687
  * Transformer that transforms values in a numeric domain to values in a range equal to the domain or to another range
142
688
  * defined by a callback function. In other words, the domain determines valid input values and, without a callback, the
@@ -839,4 +1385,4 @@ declare const ALPHABETIC_CREATOR: CharacterSetCreator;
839
1385
  */
840
1386
  declare const ALPHANUMERIC_CREATOR: CharacterSetCreator;
841
1387
 
842
- export { ALPHABETIC_CREATOR, ALPHANUMERIC_CREATOR, CharacterSetCreator, type CharacterSetValidation, CharacterSetValidator, EncryptionTransformer, Exclusion, HEXADECIMAL_CREATOR, IdentityTransformer, IteratorProxy, NUMERIC_CREATOR, RecordValidator, RegExpValidator, Sequencer, type StringValidation, type StringValidator, Transformer, type TransformerCallback, type TransformerInput, type TransformerOutput, utilityNS };
1388
+ export { ALPHABETIC_CREATOR, ALPHANUMERIC_CREATOR, CharacterSetCreator, type CharacterSetValidation, CharacterSetValidator, EncryptionTransformer, Exclusion, HEXADECIMAL_CREATOR, IdentityTransformer, NUMERIC_CREATOR, RecordValidator, RegExpValidator, Sequencer, type StringValidation, type StringValidator, Transformer, type TransformerCallback, type TransformerInput, type TransformerOutput, type UtilityLocaleStrings, i18nUtilityInit, i18nextUtility, transformIterable, utilityNS, utilityResources };