@aidc-toolkit/utility 1.0.26-beta → 1.0.28-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.
@@ -42,7 +42,7 @@ export interface CharacterSetValidation extends StringValidation {
42
42
  * Character set validator. Validates a string against a specified character set.
43
43
  */
44
44
  export class CharacterSetValidator implements StringValidator<CharacterSetValidation> {
45
- private static readonly NOT_ALL_NUMERIC_VALIDATOR = new class extends RegExpValidator {
45
+ static readonly #NOT_ALL_NUMERIC_VALIDATOR = new class extends RegExpValidator {
46
46
  /**
47
47
  * Create an error message for an all-numeric string.
48
48
  *
@@ -60,18 +60,18 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
60
60
  /**
61
61
  * Character set.
62
62
  */
63
- private readonly _characterSet: readonly string[];
63
+ readonly #characterSet: readonly string[];
64
64
 
65
65
  /**
66
66
  * Character set map, mapping each character in the character set to its index such that
67
67
  * `_characterSetMap.get(_characterSet[index]) === index`.
68
68
  */
69
- private readonly _characterSetMap: ReadonlyMap<string, number>;
69
+ readonly #characterSetMap: ReadonlyMap<string, number>;
70
70
 
71
71
  /**
72
72
  * Exclusions supported by the character set.
73
73
  */
74
- private readonly _exclusionSupport: readonly Exclusion[];
74
+ readonly #exclusionSupport: readonly Exclusion[];
75
75
 
76
76
  /**
77
77
  * Constructor.
@@ -84,7 +84,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
84
84
  * Exclusions supported by the character set. All character sets implicitly support {@linkcode Exclusions.None}.
85
85
  */
86
86
  constructor(characterSet: readonly string[], ...exclusionSupport: readonly Exclusion[]) {
87
- this._characterSet = characterSet;
87
+ this.#characterSet = characterSet;
88
88
 
89
89
  const characterSetMap = new Map<string, number>();
90
90
 
@@ -92,30 +92,30 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
92
92
  characterSetMap.set(c, index);
93
93
  });
94
94
 
95
- this._characterSetMap = characterSetMap;
95
+ this.#characterSetMap = characterSetMap;
96
96
 
97
- this._exclusionSupport = exclusionSupport;
97
+ this.#exclusionSupport = exclusionSupport;
98
98
  }
99
99
 
100
100
  /**
101
101
  * Get the character set.
102
102
  */
103
103
  get characterSet(): readonly string[] {
104
- return this._characterSet;
104
+ return this.#characterSet;
105
105
  }
106
106
 
107
107
  /**
108
108
  * Get the character set size.
109
109
  */
110
110
  get characterSetSize(): number {
111
- return this._characterSet.length;
111
+ return this.#characterSet.length;
112
112
  }
113
113
 
114
114
  /**
115
115
  * Get the exclusions supported by the character set.
116
116
  */
117
117
  get exclusionSupport(): readonly Exclusion[] {
118
- return this._exclusionSupport;
118
+ return this.#exclusionSupport;
119
119
  }
120
120
 
121
121
  /**
@@ -128,7 +128,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
128
128
  * Character at the index.
129
129
  */
130
130
  character(index: number): string {
131
- return this._characterSet[index];
131
+ return this.#characterSet[index];
132
132
  }
133
133
 
134
134
  /**
@@ -141,7 +141,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
141
141
  * Index for the character or undefined if the character is not in the character set.
142
142
  */
143
143
  characterIndex(c: string): number | undefined {
144
- return this._characterSetMap.get(c);
144
+ return this.#characterSetMap.get(c);
145
145
  }
146
146
 
147
147
  /**
@@ -154,7 +154,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
154
154
  * Array of indexes for each character or undefined if the character is not in the character set.
155
155
  */
156
156
  characterIndexes(s: string): ReadonlyArray<number | undefined> {
157
- return Array.from(s).map(c => this._characterSetMap.get(c));
157
+ return Array.from(s).map(c => this.#characterSetMap.get(c));
158
158
  }
159
159
 
160
160
  /**
@@ -167,7 +167,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
167
167
  * @returns
168
168
  * Component as a string or undefined.
169
169
  */
170
- private static componentToString(component: string | (() => string) | undefined): string | undefined {
170
+ static #componentToString(component: string | (() => string) | undefined): string | undefined {
171
171
  return typeof component === "function" ? component() : component;
172
172
  }
173
173
 
@@ -178,7 +178,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
178
178
  * Exclusion.
179
179
  */
180
180
  protected validateExclusion(exclusion: Exclusion): void {
181
- if (exclusion !== Exclusions.None && !this._exclusionSupport.includes(exclusion)) {
181
+ if (exclusion !== Exclusions.None && !this.#exclusionSupport.includes(exclusion)) {
182
182
  throw new RangeError(i18nextUtility.t("CharacterSetValidator.exclusionNotSupported", {
183
183
  exclusion
184
184
  }));
@@ -206,13 +206,13 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
206
206
 
207
207
  if (maximumLength !== undefined && maximumLength === minimumLength) {
208
208
  errorMessage = i18nextUtility.t(validation?.component === undefined ? "CharacterSetValidator.lengthMustBeEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeEqualTo", {
209
- component: CharacterSetValidator.componentToString(validation?.component),
209
+ component: CharacterSetValidator.#componentToString(validation?.component),
210
210
  length,
211
211
  exactLength: minimumLength
212
212
  });
213
213
  } else {
214
214
  errorMessage = i18nextUtility.t(validation?.component === undefined ? "CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeGreaterThanOrEqualTo", {
215
- component: CharacterSetValidator.componentToString(validation?.component),
215
+ component: CharacterSetValidator.#componentToString(validation?.component),
216
216
  length,
217
217
  minimumLength
218
218
  });
@@ -223,7 +223,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
223
223
 
224
224
  if (maximumLength !== undefined && length > maximumLength) {
225
225
  throw new RangeError(i18nextUtility.t(validation?.component === undefined ? "CharacterSetValidator.lengthMustBeLessThanOrEqualTo" : "CharacterSetValidator.lengthOfComponentMustBeLessThanOrEqualTo", {
226
- component: CharacterSetValidator.componentToString(validation?.component),
226
+ component: CharacterSetValidator.#componentToString(validation?.component),
227
227
  length,
228
228
  maximumLength
229
229
  }));
@@ -234,7 +234,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
234
234
 
235
235
  if (index !== -1) {
236
236
  throw new RangeError(i18nextUtility.t(validation?.component === undefined ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
237
- component: CharacterSetValidator.componentToString(validation?.component),
237
+ component: CharacterSetValidator.#componentToString(validation?.component),
238
238
  c: s.charAt(index),
239
239
  position: index + (validation?.positionOffset ?? 0) + 1
240
240
  }));
@@ -250,7 +250,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
250
250
  case Exclusions.FirstZero:
251
251
  if (s.startsWith("0")) {
252
252
  throw new RangeError(i18nextUtility.t(validation.component === undefined ? "CharacterSetValidator.invalidCharacterAtPosition" : "CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
253
- component: CharacterSetValidator.componentToString(validation.component),
253
+ component: CharacterSetValidator.#componentToString(validation.component),
254
254
  c: "0",
255
255
  position: (validation.positionOffset ?? 0) + 1
256
256
  }));
@@ -258,7 +258,7 @@ export class CharacterSetValidator implements StringValidator<CharacterSetValida
258
258
  break;
259
259
 
260
260
  case Exclusions.AllNumeric:
261
- CharacterSetValidator.NOT_ALL_NUMERIC_VALIDATOR.validate(s);
261
+ CharacterSetValidator.#NOT_ALL_NUMERIC_VALIDATOR.validate(s);
262
262
  break;
263
263
  }
264
264
  }
@@ -277,7 +277,7 @@ export class CharacterSetCreator extends CharacterSetValidator {
277
277
  /**
278
278
  * Powers of 10 from 1 (`10**0`) to `10**MAXIMUM_STRING_LENGTH`.
279
279
  */
280
- private static readonly _powersOf10: readonly bigint[] = CharacterSetCreator.createPowersOf(10);
280
+ static #POWERS_OF_10?: readonly bigint[];
281
281
 
282
282
  /**
283
283
  * Create powers of a given base from 1 (`base**0`) to `base**MAXIMUM_STRING_LENGTH`.
@@ -288,7 +288,7 @@ export class CharacterSetCreator extends CharacterSetValidator {
288
288
  * @returns
289
289
  * Array of powers of base.
290
290
  */
291
- private static createPowersOf(base: number): readonly bigint[] {
291
+ static #createPowersOf(base: number): readonly bigint[] {
292
292
  const powersOf = new Array<bigint>(this.MAXIMUM_STRING_LENGTH + 1);
293
293
 
294
294
  const baseN = BigInt(base);
@@ -310,28 +310,31 @@ export class CharacterSetCreator extends CharacterSetValidator {
310
310
  * `10**power`.
311
311
  */
312
312
  static powerOf10(power: number): bigint {
313
- return this._powersOf10[power];
313
+ // Initialization is here due to order in which class is constructed causing errors reading undefined.
314
+ CharacterSetCreator.#POWERS_OF_10 ??= CharacterSetCreator.#createPowersOf(10);
315
+
316
+ return CharacterSetCreator.#POWERS_OF_10[power];
314
317
  }
315
318
 
316
319
  /**
317
320
  * Character set size as big integer, cached for performance purposes.
318
321
  */
319
- private readonly _characterSetSizeN: bigint;
322
+ readonly #characterSetSizeN: bigint;
320
323
 
321
324
  /**
322
325
  * Character set size minus 1 as big integer, cached for performance purposes.
323
326
  */
324
- private readonly _characterSetSizeMinusOneN: bigint;
327
+ readonly #characterSetSizeMinusOneN: bigint;
325
328
 
326
329
  /**
327
330
  * Domains for every length for every supported {@linkcode Exclusions}.
328
331
  */
329
- private readonly _exclusionDomains: ReadonlyArray<readonly bigint[]>;
332
+ readonly #exclusionDomains: ReadonlyArray<readonly bigint[]>;
330
333
 
331
334
  /**
332
335
  * Values that would generate all zeros in the created string.
333
336
  */
334
- private readonly _allZerosValues: readonly bigint[];
337
+ readonly #allZerosValues: readonly bigint[];
335
338
 
336
339
  /**
337
340
  * Constructor.
@@ -346,12 +349,12 @@ export class CharacterSetCreator extends CharacterSetValidator {
346
349
  constructor(characterSet: readonly string[], ...exclusionSupport: readonly Exclusion[]) {
347
350
  super(characterSet, ...exclusionSupport);
348
351
 
349
- this._characterSetSizeN = BigInt(this.characterSetSize);
350
- this._characterSetSizeMinusOneN = BigInt(this.characterSetSize - 1);
352
+ this.#characterSetSizeN = BigInt(this.characterSetSize);
353
+ this.#characterSetSizeMinusOneN = BigInt(this.characterSetSize - 1);
351
354
 
352
355
  const exclusionDomains: Array<readonly bigint[]> = [];
353
356
 
354
- const exclusionNoneDomains = CharacterSetCreator.createPowersOf(this.characterSetSize);
357
+ const exclusionNoneDomains = CharacterSetCreator.#createPowersOf(this.characterSetSize);
355
358
 
356
359
  exclusionDomains[Exclusions.None] = exclusionNoneDomains;
357
360
 
@@ -367,7 +370,7 @@ export class CharacterSetCreator extends CharacterSetValidator {
367
370
 
368
371
  for (let index = 1; index <= CharacterSetCreator.MAXIMUM_STRING_LENGTH; index++) {
369
372
  // Domain excludes zero as the first character and so works with previous exclusion none domain.
370
- exclusionFirstZeroDomains[index] = this._characterSetSizeMinusOneN * exclusionNoneDomains[index - 1];
373
+ exclusionFirstZeroDomains[index] = this.#characterSetSizeMinusOneN * exclusionNoneDomains[index - 1];
371
374
  }
372
375
 
373
376
  exclusionDomains[Exclusions.FirstZero] = exclusionFirstZeroDomains;
@@ -412,18 +415,18 @@ export class CharacterSetCreator extends CharacterSetValidator {
412
415
 
413
416
  allZerosValues[index] = allZerosValue;
414
417
 
415
- allZerosValue = allZerosValue * this._characterSetSizeN + zeroIndex;
418
+ allZerosValue = allZerosValue * this.#characterSetSizeN + zeroIndex;
416
419
  }
417
420
 
418
- this._allZerosValues = allZerosValues;
421
+ this.#allZerosValues = allZerosValues;
419
422
 
420
423
  exclusionDomains[Exclusions.AllNumeric] = exclusionAllNumericDomains;
421
424
  } else {
422
425
  // Empty array obviates need for non-null assertion while still forcing error if indexed due to a bug.
423
- this._allZerosValues = [];
426
+ this.#allZerosValues = [];
424
427
  }
425
428
 
426
- this._exclusionDomains = exclusionDomains;
429
+ this.#exclusionDomains = exclusionDomains;
427
430
  }
428
431
 
429
432
  /**
@@ -435,8 +438,8 @@ export class CharacterSetCreator extends CharacterSetValidator {
435
438
  * @returns
436
439
  * `characterSetSize**power`.
437
440
  */
438
- private powerOfSize(power: number): bigint {
439
- return this._exclusionDomains[Exclusions.None][power];
441
+ #powerOfSize(power: number): bigint {
442
+ return this.#exclusionDomains[Exclusions.None][power];
440
443
  }
441
444
 
442
445
  /**
@@ -454,7 +457,7 @@ export class CharacterSetCreator extends CharacterSetValidator {
454
457
  * @returns
455
458
  * Shift required to skip all all-numeric strings.
456
459
  */
457
- private allNumericShift(shiftForward: boolean, length: number, value: bigint): bigint {
460
+ #allNumericShift(shiftForward: boolean, length: number, value: bigint): bigint {
458
461
  let shift: bigint;
459
462
 
460
463
  if (length === 0) {
@@ -466,7 +469,7 @@ export class CharacterSetCreator extends CharacterSetValidator {
466
469
  // Now dealing with individual characters; shift by 10 to skip numeric characters.
467
470
  shift = 10n;
468
471
  } else {
469
- const powerOfSize = this.powerOfSize(length);
472
+ const powerOfSize = this.#powerOfSize(length);
470
473
  const powerOf10 = CharacterSetCreator.powerOf10(length);
471
474
 
472
475
  // Calculate the gap to the next numeric string of equal length with incremental first character.
@@ -480,7 +483,7 @@ export class CharacterSetCreator extends CharacterSetValidator {
480
483
  shift = CharacterSetCreator.powerOf10(length + 1);
481
484
  } else {
482
485
  // 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.
483
- shift = gaps * powerOf10 + this.allNumericShift(shiftForward, length - 1, value - gaps * gap);
486
+ shift = gaps * powerOf10 + this.#allNumericShift(shiftForward, length - 1, value - gaps * gap);
484
487
  }
485
488
  }
486
489
 
@@ -493,7 +496,7 @@ export class CharacterSetCreator extends CharacterSetValidator {
493
496
  * @param length
494
497
  * Length.
495
498
  */
496
- private validateLength(length: number): void {
499
+ #validateLength(length: number): void {
497
500
  if (length < 0) {
498
501
  throw new RangeError(i18nextUtility.t("CharacterSetValidator.lengthMustBeGreaterThanOrEqualTo", {
499
502
  length,
@@ -537,13 +540,13 @@ export class CharacterSetCreator extends CharacterSetValidator {
537
540
  * String(s) created from the value(s).
538
541
  */
539
542
  create<TTransformerInput extends TransformerInput<number | bigint>>(length: number, valueOrValues: TTransformerInput, exclusion: Exclusion = Exclusions.None, tweak?: number | bigint, creatorCallback?: IndexedCallback<string, string>): TransformerOutput<TTransformerInput, string> {
540
- this.validateLength(length);
543
+ this.#validateLength(length);
541
544
  this.validateExclusion(exclusion);
542
545
 
543
546
  // Zero value in ternary else obviates need for non-null assertion.
544
- const allZerosValue = exclusion === Exclusions.AllNumeric ? this._allZerosValues[length] : 0n;
547
+ const allZerosValue = exclusion === Exclusions.AllNumeric ? this.#allZerosValues[length] : 0n;
545
548
 
546
- const transformer = Transformer.get(this._exclusionDomains[exclusion][length], tweak);
549
+ const transformer = Transformer.get(this.#exclusionDomains[exclusion][length], tweak);
547
550
 
548
551
  return transformer.forward(valueOrValues, (transformedValue, index) => {
549
552
  let s = "";
@@ -554,21 +557,21 @@ export class CharacterSetCreator extends CharacterSetValidator {
554
557
 
555
558
  if (exclusion === Exclusions.AllNumeric && convertValue >= allZerosValue) {
556
559
  // Value to convert is shifted by the number of all-numeric strings that occur at or prior to it.
557
- convertValue += this.allNumericShift(true, length, convertValue - allZerosValue);
560
+ convertValue += this.#allNumericShift(true, length, convertValue - allZerosValue);
558
561
  }
559
562
 
560
563
  // Build string from right to left excluding the first character.
561
564
  for (let position = length - 1; position > 0; position--) {
562
- const nextConvertValue = convertValue / this._characterSetSizeN;
565
+ const nextConvertValue = convertValue / this.#characterSetSizeN;
563
566
 
564
567
  // First step is effectively a modulus calculation.
565
- s = this.character(Number(convertValue - nextConvertValue * this._characterSetSizeN)) + s;
568
+ s = this.character(Number(convertValue - nextConvertValue * this.#characterSetSizeN)) + s;
566
569
 
567
570
  convertValue = nextConvertValue;
568
571
  }
569
572
 
570
573
  // Zero is first in the character set for those that support excluding first zero.
571
- s = this.character(exclusion === Exclusions.FirstZero ? Number(convertValue % this._characterSetSizeMinusOneN) + 1 : Number(convertValue % this._characterSetSizeN)) + s;
574
+ s = this.character(exclusion === Exclusions.FirstZero ? Number(convertValue % this.#characterSetSizeMinusOneN) + 1 : Number(convertValue % this.#characterSetSizeN)) + s;
572
575
  }
573
576
 
574
577
  return creatorCallback === undefined ? s : creatorCallback(s, index);
@@ -594,7 +597,7 @@ export class CharacterSetCreator extends CharacterSetValidator {
594
597
  valueFor(s: string, exclusion: Exclusion = Exclusions.None, tweak?: number | bigint): bigint {
595
598
  const length = s.length;
596
599
 
597
- this.validateLength(length);
600
+ this.#validateLength(length);
598
601
  this.validateExclusion(exclusion);
599
602
 
600
603
  const characterSetSizeN = BigInt(this.characterSetSize);
@@ -628,15 +631,15 @@ export class CharacterSetCreator extends CharacterSetValidator {
628
631
  }, 0n);
629
632
 
630
633
  if (exclusion === Exclusions.AllNumeric) {
631
- const allZerosValue = this._allZerosValues[length];
634
+ const allZerosValue = this.#allZerosValues[length];
632
635
 
633
636
  if (value >= allZerosValue) {
634
637
  // Call will ensure that string is not all-numeric.
635
- value -= this.allNumericShift(false, length, value - allZerosValue);
638
+ value -= this.#allNumericShift(false, length, value - allZerosValue);
636
639
  }
637
640
  }
638
641
 
639
- return Transformer.get(this._exclusionDomains[exclusion][length], tweak).reverse(value);
642
+ return Transformer.get(this.#exclusionDomains[exclusion][length], tweak).reverse(value);
640
643
  }
641
644
  }
642
645
 
package/src/record.ts CHANGED
@@ -12,12 +12,12 @@ export class RecordValidator<T> implements StringValidator {
12
12
  /**
13
13
  * Type name for error message.
14
14
  */
15
- private readonly _typeName: string;
15
+ readonly #typeName: string;
16
16
 
17
17
  /**
18
18
  * Record in which to look up keys.
19
19
  */
20
- private readonly _record: Readonly<Record<string, T>>;
20
+ readonly #record: Readonly<Record<string, T>>;
21
21
 
22
22
  /**
23
23
  * Constructor.
@@ -29,22 +29,22 @@ export class RecordValidator<T> implements StringValidator {
29
29
  * Record in which to look up keys.
30
30
  */
31
31
  constructor(typeName: string, record: Readonly<Record<string, T>>) {
32
- this._typeName = typeName;
33
- this._record = record;
32
+ this.#typeName = typeName;
33
+ this.#record = record;
34
34
  }
35
35
 
36
36
  /**
37
37
  * Get the type name.
38
38
  */
39
39
  get typeName(): string {
40
- return this._typeName;
40
+ return this.#typeName;
41
41
  }
42
42
 
43
43
  /**
44
44
  * Get the record.
45
45
  */
46
46
  get record(): Readonly<Record<string, T>> {
47
- return this._record;
47
+ return this.#record;
48
48
  }
49
49
 
50
50
  /**
package/src/reg-exp.ts CHANGED
@@ -14,7 +14,7 @@ export class RegExpValidator implements StringValidator {
14
14
  /**
15
15
  * Regular expression.
16
16
  */
17
- private readonly _regExp: RegExp;
17
+ readonly #regExp: RegExp;
18
18
 
19
19
  /**
20
20
  * Constructor.
@@ -23,14 +23,14 @@ export class RegExpValidator implements StringValidator {
23
23
  * Regular expression. See {@link RegExpValidator | class documentation} for notes.
24
24
  */
25
25
  constructor(regExp: RegExp) {
26
- this._regExp = regExp;
26
+ this.#regExp = regExp;
27
27
  }
28
28
 
29
29
  /**
30
30
  * Get the regular expression.
31
31
  */
32
32
  get regExp(): RegExp {
33
- return this._regExp;
33
+ return this.#regExp;
34
34
  }
35
35
 
36
36
  /**
@@ -53,7 +53,7 @@ export class RegExpValidator implements StringValidator {
53
53
  * @inheritDoc
54
54
  */
55
55
  validate(s: string): void {
56
- if (!this._regExp.test(s)) {
56
+ if (!this.#regExp.test(s)) {
57
57
  throw new RangeError(this.createErrorMessage(s));
58
58
  }
59
59
  }
package/src/sequence.ts CHANGED
@@ -5,32 +5,32 @@ export class Sequence implements Iterable<bigint> {
5
5
  /**
6
6
  * Start value (inclusive).
7
7
  */
8
- private readonly _startValue: bigint;
8
+ readonly #startValue: bigint;
9
9
 
10
10
  /**
11
11
  * End value (exclusive).
12
12
  */
13
- private readonly _endValue: bigint;
13
+ readonly #endValue: bigint;
14
14
 
15
15
  /**
16
16
  * Count of values.
17
17
  */
18
- private readonly _count: number;
18
+ readonly #count: number;
19
19
 
20
20
  /**
21
21
  * Delta to the next value; equal to the sign of the count.
22
22
  */
23
- private readonly _nextDelta: 1n | -1n;
23
+ readonly #nextDelta: 1n | -1n;
24
24
 
25
25
  /**
26
26
  * Minimum value (inclusive).
27
27
  */
28
- private readonly _minimumValue: bigint;
28
+ readonly #minimumValue: bigint;
29
29
 
30
30
  /**
31
31
  * Maximum value (inclusive).
32
32
  */
33
- private readonly _maximumValue: bigint;
33
+ readonly #maximumValue: bigint;
34
34
 
35
35
  /**
36
36
  * Constructor.
@@ -43,18 +43,18 @@ export class Sequence implements Iterable<bigint> {
43
43
  * start value.
44
44
  */
45
45
  constructor(startValue: number | bigint, count: number) {
46
- this._startValue = BigInt(startValue);
47
- this._endValue = this._startValue + BigInt(count);
48
- this._count = count;
46
+ this.#startValue = BigInt(startValue);
47
+ this.#endValue = this.#startValue + BigInt(count);
48
+ this.#count = count;
49
49
 
50
50
  if (count >= 0) {
51
- this._nextDelta = 1n;
52
- this._minimumValue = this._startValue;
53
- this._maximumValue = this._endValue - 1n;
51
+ this.#nextDelta = 1n;
52
+ this.#minimumValue = this.#startValue;
53
+ this.#maximumValue = this.#endValue - 1n;
54
54
  } else {
55
- this._nextDelta = -1n;
56
- this._minimumValue = this._endValue + 1n;
57
- this._maximumValue = this._startValue;
55
+ this.#nextDelta = -1n;
56
+ this.#minimumValue = this.#endValue + 1n;
57
+ this.#maximumValue = this.#startValue;
58
58
  }
59
59
  }
60
60
 
@@ -62,35 +62,35 @@ export class Sequence implements Iterable<bigint> {
62
62
  * Get the start value (inclusive).
63
63
  */
64
64
  get startValue(): bigint {
65
- return this._startValue;
65
+ return this.#startValue;
66
66
  }
67
67
 
68
68
  /**
69
69
  * Get the end value (exclusive).
70
70
  */
71
71
  get endValue(): bigint {
72
- return this._endValue;
72
+ return this.#endValue;
73
73
  }
74
74
 
75
75
  /**
76
76
  * Get the count of values.
77
77
  */
78
78
  get count(): number {
79
- return this._count;
79
+ return this.#count;
80
80
  }
81
81
 
82
82
  /**
83
83
  * Get the minimum value (inclusive).
84
84
  */
85
85
  get minimumValue(): bigint {
86
- return this._minimumValue;
86
+ return this.#minimumValue;
87
87
  }
88
88
 
89
89
  /**
90
90
  * Get the maximum value (inclusive).
91
91
  */
92
92
  get maximumValue(): bigint {
93
- return this._maximumValue;
93
+ return this.#maximumValue;
94
94
  }
95
95
 
96
96
  /**
@@ -100,7 +100,7 @@ export class Sequence implements Iterable<bigint> {
100
100
  * Next value in sequence.
101
101
  */
102
102
  * [Symbol.iterator](): Generator<bigint> {
103
- for (let value = this._startValue; value !== this._endValue; value += this._nextDelta) {
103
+ for (let value = this.#startValue; value !== this.#endValue; value += this.#nextDelta) {
104
104
  yield value;
105
105
  }
106
106
  }