@aidc-toolkit/utility 1.0.23-beta → 1.0.25-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.
Files changed (65) hide show
  1. package/README.md +30 -30
  2. package/dist/index.cjs +3570 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +953 -0
  5. package/dist/index.d.ts +953 -26
  6. package/dist/index.js +3505 -8
  7. package/dist/index.js.map +1 -1
  8. package/package.json +7 -11
  9. package/src/character-set.ts +20 -19
  10. package/src/exclusion.ts +6 -1
  11. package/src/index.ts +9 -9
  12. package/src/locale/i18n.ts +3 -5
  13. package/src/locale/i18next.d.ts +1 -1
  14. package/src/record.ts +2 -2
  15. package/src/reg-exp.ts +7 -7
  16. package/src/string.ts +3 -3
  17. package/src/transformer.ts +19 -18
  18. package/test/record.test.ts +3 -1
  19. package/tsup.config.ts +3 -0
  20. package/typedoc.json +1 -3
  21. package/dist/character-set.d.ts +0 -307
  22. package/dist/character-set.d.ts.map +0 -1
  23. package/dist/character-set.js +0 -563
  24. package/dist/character-set.js.map +0 -1
  25. package/dist/exclusion.d.ts +0 -22
  26. package/dist/exclusion.d.ts.map +0 -1
  27. package/dist/exclusion.js +0 -18
  28. package/dist/exclusion.js.map +0 -1
  29. package/dist/index.d.ts.map +0 -1
  30. package/dist/iterable-utility.d.ts +0 -39
  31. package/dist/iterable-utility.d.ts.map +0 -1
  32. package/dist/iterable-utility.js +0 -35
  33. package/dist/iterable-utility.js.map +0 -1
  34. package/dist/locale/en/locale-resources.d.ts +0 -33
  35. package/dist/locale/en/locale-resources.d.ts.map +0 -1
  36. package/dist/locale/en/locale-resources.js +0 -32
  37. package/dist/locale/en/locale-resources.js.map +0 -1
  38. package/dist/locale/fr/locale-resources.d.ts +0 -33
  39. package/dist/locale/fr/locale-resources.d.ts.map +0 -1
  40. package/dist/locale/fr/locale-resources.js +0 -32
  41. package/dist/locale/fr/locale-resources.js.map +0 -1
  42. package/dist/locale/i18n.d.ts +0 -27
  43. package/dist/locale/i18n.d.ts.map +0 -1
  44. package/dist/locale/i18n.js +0 -35
  45. package/dist/locale/i18n.js.map +0 -1
  46. package/dist/record.d.ts +0 -44
  47. package/dist/record.d.ts.map +0 -1
  48. package/dist/record.js +0 -58
  49. package/dist/record.js.map +0 -1
  50. package/dist/reg-exp.d.ts +0 -43
  51. package/dist/reg-exp.d.ts.map +0 -1
  52. package/dist/reg-exp.js +0 -55
  53. package/dist/reg-exp.js.map +0 -1
  54. package/dist/sequence.d.ts +0 -68
  55. package/dist/sequence.d.ts.map +0 -1
  56. package/dist/sequence.js +0 -96
  57. package/dist/sequence.js.map +0 -1
  58. package/dist/string.d.ts +0 -25
  59. package/dist/string.d.ts.map +0 -1
  60. package/dist/string.js +0 -2
  61. package/dist/string.js.map +0 -1
  62. package/dist/transformer.d.ts +0 -346
  63. package/dist/transformer.d.ts.map +0 -1
  64. package/dist/transformer.js +0 -456
  65. package/dist/transformer.js.map +0 -1
package/README.md CHANGED
@@ -24,9 +24,9 @@ To provide the most flexibility and to handle the most significant demands of th
24
24
 
25
25
  Many of AIDC processes can be reduced to a simple statement about sequences:
26
26
 
27
- * "Give me a million serial numbers for manufacturing."
28
- * "Generate a handful of GTINs for my new product line."
29
- * "Label the containers in the shipping area with SSCCs."
27
+ - "Give me a million serial numbers for manufacturing."
28
+ - "Generate a handful of GTINs for my new product line."
29
+ - "Label the containers in the shipping area with SSCCs."
30
30
 
31
31
  Each statement has a quantity and an output. Implicit in them is the requirement that the generated output be unique, not only within itself, but also within any previous outputs generated. A [`Sequence`](https://aidc-toolkit.com/api/Utility/classes/Sequence.html) is simply a utility to generate a sequence of integers given a start value and a count.
32
32
 
@@ -34,7 +34,7 @@ Each statement has a quantity and an output. Implicit in them is the requirement
34
34
  >
35
35
  > The AIDC Toolkit is not responsible for maintaining the history of any sequence. It is up to the application to ensure that the start value and count don't overlap with any other start value and count for a sequence used for the same purpose.
36
36
 
37
- #### Creating and using a sequence
37
+ #### Creating and Using a Sequence
38
38
 
39
39
  1. Create a sequence with a start value and a count. The count is typically positive, which means that the sequence runs from the start value up. If negative, the sequence runs from the start value down.
40
40
  ```typescript
@@ -54,7 +54,7 @@ Each statement has a quantity and an output. Implicit in them is the requirement
54
54
  ```
55
55
  * Pass it to a function.
56
56
  ```typescript
57
- // Crate a sequence of 10-character hexadecimal strings.
57
+ // Create a sequence of 10-character hexadecimal strings.
58
58
  const stringSequence = HEXADECIMAL_STRING_CREATOR.create(10, sequence);
59
59
  ```
60
60
 
@@ -122,7 +122,7 @@ flowchart TD
122
122
 
123
123
  ## Strings
124
124
 
125
- ### String validation
125
+ ### String Validation
126
126
 
127
127
  Validation is a requirement for any application. The AIDC Toolkit provides a simple but extensible validation framework built on two interfaces: [`StringValidation`](https://aidc-toolkit.com/api/Utility/interfaces/StringValidation.html) and [`StringValidator`](https://aidc-toolkit.com/api/Utility/interfaces/StringValidator.html). The two are related in that an interface extending `StringValidation` may be passed as a parameter to the [`validate()`](https://aidc-toolkit.com/api/Utility/interfaces/StringValidator#validate.html) method of a class implementing `StringValidator` to restrict validation further than the default. For example, [`CharacterSetValidator`](https://aidc-toolkit.com/api/Utility/classes/CharacterSetValidator.html) accepts a [`CharacterSetValidation`](https://aidc-toolkit.com/api/Utility/interfaces/CharacterSetValidation.html) object that can constrain the length and limit the way numeric values are expressed (e.g., exclude zero as the first character or exclude strings that are all numeric).
128
128
 
@@ -130,41 +130,41 @@ The `StringValidation` interface is a placeholder only; it's empty, which, in a
130
130
 
131
131
  If a string passed to a `validate()` method is valid, the method returns; if not, a [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) is thrown.
132
132
 
133
- #### Predefined validators
133
+ #### Predefined Validators
134
134
 
135
135
  The following validator types are predefined:
136
136
 
137
- * [Regular expression](https://aidc-toolkit.com/api/Utility/classes/RegExpValidator.html)
138
- * Validates a string against a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions).
139
- * [Record](https://aidc-toolkit.com/api/Utility/classes/RecordValidator.html)
140
- * Validates a string by looking it up in a [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type) object.
141
- * [Character set](https://aidc-toolkit.com/api/Utility/classes/CharacterSetValidator.html)
142
- * Validates a string by ensuring that each character is within a defined character set, with additional validation parameters optionally constraining the length and limiting the way numeric values are expressed. Predefined character set validators are:
143
- * [Numeric (0-9)](https://aidc-toolkit.com/api/Utility/variables/NUMERIC_VALIDATOR.html)
144
- * [Hexadecimal (0-9, A-F)](https://aidc-toolkit.com/api/Utility/variables/HEXADECIMAL_VALIDATOR.html)
145
- * [Alphabetic (A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHABETIC_VALIDATOR.html)
146
- * [Alphanumeric (0-9, A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHANUMERIC_VALIDATOR.html)
137
+ - [Regular expression](https://aidc-toolkit.com/api/Utility/classes/RegExpValidator.html)
138
+ - Validates a string against a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions).
139
+ - [Record](https://aidc-toolkit.com/api/Utility/classes/RecordValidator.html)
140
+ - Validates a string by looking it up in a [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type) object.
141
+ - [Character set](https://aidc-toolkit.com/api/Utility/classes/CharacterSetValidator.html)
142
+ - Validates a string by ensuring that each character is within a defined character set, with additional validation parameters optionally constraining the length and limiting the way numeric values are expressed. Predefined character set validators are:
143
+ - [Numeric (0-9)](https://aidc-toolkit.com/api/Utility/variables/NUMERIC_VALIDATOR.html)
144
+ - [Hexadecimal (0-9, A-F)](https://aidc-toolkit.com/api/Utility/variables/HEXADECIMAL_VALIDATOR.html)
145
+ - [Alphabetic (A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHABETIC_VALIDATOR.html)
146
+ - [Alphanumeric (0-9, A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHANUMERIC_VALIDATOR.html)
147
147
 
148
- ### String creation
148
+ ### String Creation
149
149
 
150
150
  String creation varies depending on the type of string being created, so there's no single interface that can be implemented. There is a pattern, however:
151
151
 
152
- * Creation is done via a `create()` method. If the class can create more than one type of string, it can define additional `create*NNN*()` methods as appropriate.
153
- * The `create()` (or `create*NNN*()`) method is overloaded, with a parameter accepting either a single value to create a single string or multiple values (as `Iterable`) to create multiple strings.
154
- * If the value to create a string is numeric (`number` or `bigint`), the method uses a [`Transformer`](https://aidc-toolkit.com/api/Utility/classes/Transformer.html) and supports sparse creation.
155
- * Because of this, passing in a [`Sequence`](https://aidc-toolkit.com/api/Utility/classes/Sequence.html) is strongly recommended when creating multiple strings.
152
+ - Creation is done via a `create()` method. If the class can create more than one type of string, it can define additional `create*NNN*()` methods as appropriate.
153
+ - The `create()` (or `create*NNN*()`) method is overloaded, with a parameter accepting either a single value to create a single string or multiple values (as `Iterable`) to create multiple strings.
154
+ - If the value to create a string is numeric (`number` or `bigint`), the method uses a [`Transformer`](https://aidc-toolkit.com/api/Utility/classes/Transformer.html) and supports sparse creation.
155
+ - Because of this, passing in a [`Sequence`](https://aidc-toolkit.com/api/Utility/classes/Sequence.html) is strongly recommended when creating multiple strings.
156
156
 
157
- #### Predefined creators
157
+ #### Predefined Creators
158
158
 
159
159
  The following creator types are predefined:
160
160
 
161
- * [Character set](https://aidc-toolkit.com/api/Utility/classes/CharacterSetCreator.html)
162
- * Creates strings by mapping numeric (`number` and `bigint`) values to fixed-length string representations using the character set as the "digits" of the string. Predefined character set creators are:
163
- * [Numeric (0-9)](https://aidc-toolkit.com/api/Utility/variables/NUMERIC_CREATOR.html)
164
- * [Hexadecimal (0-9, A-F)](https://aidc-toolkit.com/api/Utility/variables/HEXADECIMAL_CREATOR.html)
165
- * [Alphabetic (A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHABETIC_CREATOR.html)
166
- * [Alphanumeric (0-9, A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHANUMERIC_CREATOR.html)
161
+ - [Character set](https://aidc-toolkit.com/api/Utility/classes/CharacterSetCreator.html)
162
+ - Creates strings by mapping numeric (`number` and `bigint`) values to fixed-length string representations using the character set as the "digits" of the string. Predefined character set creators are:
163
+ - [Numeric (0-9)](https://aidc-toolkit.com/api/Utility/variables/NUMERIC_CREATOR.html)
164
+ - [Hexadecimal (0-9, A-F)](https://aidc-toolkit.com/api/Utility/variables/HEXADECIMAL_CREATOR.html)
165
+ - [Alphabetic (A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHABETIC_CREATOR.html)
166
+ - [Alphanumeric (0-9, A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHANUMERIC_CREATOR.html)
167
167
 
168
- #### Output restriction
168
+ #### Output Restriction
169
169
 
170
170
  As with string validators, string creators can restrict their output to meet the needs of certain use cases. For example, when creating serial numbers, it may be necessary to generate values that either don't start with a zero (to prevent leading zeros from being dropped by other applications) or that aren't composed entirely of digits (to prevent strings from being interpreted as numbers).