@aidc-toolkit/utility 1.0.39-beta → 1.0.40-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -18
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Many of AIDC processes can be reduced to a simple statement about sequences:
|
|
|
24
24
|
- "Generate a handful of GTINs for my new product line."
|
|
25
25
|
- "Label the containers in the shipping area with SSCCs."
|
|
26
26
|
|
|
27
|
-
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.
|
|
27
|
+
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/v1.0/api/Utility/classes/Sequence.html) is simply a utility to generate a sequence of integers given a start value and a count.
|
|
28
28
|
|
|
29
29
|
> [!TIP]
|
|
30
30
|
>
|
|
@@ -90,9 +90,9 @@ The sequence is statistically random and a counterfeiter is highly unlikely to g
|
|
|
90
90
|
|
|
91
91
|
### Sequence and Transformer
|
|
92
92
|
|
|
93
|
-
The [`Transformer`](https://aidc-toolkit.com/api/Utility/classes/Transformer.html) class underlies most AIDC Toolkit operations involved in string creation. The [`forward()`](https://aidc-toolkit.com/api/Utility/classes/Transformer.html#forward) method takes either a single `number` or `bigint` value or an `Iterable<number | bigint>` of values. This provides maximum flexibility, but it comes at a cost. All inputs are validated prior to transformation, which can add to the system load when transforming a large number of values.
|
|
93
|
+
The [`Transformer`](https://aidc-toolkit.com/v1.0/api/Utility/classes/Transformer.html) class underlies most AIDC Toolkit operations involved in string creation. The [`forward()`](https://aidc-toolkit.com/v1.0/api/Utility/classes/Transformer.html#forward) method takes either a single `number` or `bigint` value or an `Iterable<number | bigint>` of values. This provides maximum flexibility, but it comes at a cost. All inputs are validated prior to transformation, which can add to the system load when transforming a large number of values.
|
|
94
94
|
|
|
95
|
-
When dealing with `Iterable` inputs, transformers will recognize [`Sequence`](https://aidc-toolkit.com/api/Utility/classes/Sequence.html) objects and validate the start value and count at the beginning rather than each value individually as it is transformed. This reduces the number of validations from however many entries there are in an `Iterable` object to two. It also ensures that the client code deals with errors at the very beginning rather than in the middle of its processing.
|
|
95
|
+
When dealing with `Iterable` inputs, transformers will recognize [`Sequence`](https://aidc-toolkit.com/v1.0/api/Utility/classes/Sequence.html) objects and validate the start value and count at the beginning rather than each value individually as it is transformed. This reduces the number of validations from however many entries there are in an `Iterable` object to two. It also ensures that the client code deals with errors at the very beginning rather than in the middle of its processing.
|
|
96
96
|
|
|
97
97
|
```mermaid
|
|
98
98
|
flowchart TD
|
|
@@ -120,7 +120,7 @@ flowchart TD
|
|
|
120
120
|
|
|
121
121
|
### String Validation
|
|
122
122
|
|
|
123
|
-
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).
|
|
123
|
+
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/v1.0/api/Utility/interfaces/StringValidation.html) and [`StringValidator`](https://aidc-toolkit.com/v1.0/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/v1.0/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/v1.0/api/Utility/classes/CharacterSetValidator.html) accepts a [`CharacterSetValidation`](https://aidc-toolkit.com/v1.0/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).
|
|
124
124
|
|
|
125
125
|
The `StringValidation` interface is a placeholder only; it's empty, which, in a structurally typed language like TypeScript, matches any object, so it's up to `StringValidator` implementations to decide what the implementation type should be.
|
|
126
126
|
|
|
@@ -130,16 +130,16 @@ If a string passed to a `validate()` method is valid, the method returns; if not
|
|
|
130
130
|
|
|
131
131
|
The following validator types are predefined:
|
|
132
132
|
|
|
133
|
-
- [Regular expression](https://aidc-toolkit.com/api/Utility/classes/RegExpValidator.html)
|
|
133
|
+
- [Regular expression](https://aidc-toolkit.com/v1.0/api/Utility/classes/RegExpValidator.html)
|
|
134
134
|
- Validates a string against a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions).
|
|
135
|
-
- [Record](https://aidc-toolkit.com/api/Utility/classes/RecordValidator.html)
|
|
135
|
+
- [Record](https://aidc-toolkit.com/v1.0/api/Utility/classes/RecordValidator.html)
|
|
136
136
|
- Validates a string by looking it up in a [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type) object.
|
|
137
|
-
- [Character set](https://aidc-toolkit.com/api/Utility/classes/CharacterSetValidator.html)
|
|
137
|
+
- [Character set](https://aidc-toolkit.com/v1.0/api/Utility/classes/CharacterSetValidator.html)
|
|
138
138
|
- 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:
|
|
139
|
-
- [Numeric (0-9)](https://aidc-toolkit.com/api/Utility/variables/NUMERIC_VALIDATOR.html)
|
|
140
|
-
- [Hexadecimal (0-9, A-F)](https://aidc-toolkit.com/api/Utility/variables/HEXADECIMAL_VALIDATOR.html)
|
|
141
|
-
- [Alphabetic (A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHABETIC_VALIDATOR.html)
|
|
142
|
-
- [Alphanumeric (0-9, A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHANUMERIC_VALIDATOR.html)
|
|
139
|
+
- [Numeric (0-9)](https://aidc-toolkit.com/v1.0/api/Utility/variables/NUMERIC_VALIDATOR.html)
|
|
140
|
+
- [Hexadecimal (0-9, A-F)](https://aidc-toolkit.com/v1.0/api/Utility/variables/HEXADECIMAL_VALIDATOR.html)
|
|
141
|
+
- [Alphabetic (A-Z)](https://aidc-toolkit.com/v1.0/api/Utility/variables/ALPHABETIC_VALIDATOR.html)
|
|
142
|
+
- [Alphanumeric (0-9, A-Z)](https://aidc-toolkit.com/v1.0/api/Utility/variables/ALPHANUMERIC_VALIDATOR.html)
|
|
143
143
|
|
|
144
144
|
### String Creation
|
|
145
145
|
|
|
@@ -147,19 +147,19 @@ String creation varies depending on the type of string being created, so there's
|
|
|
147
147
|
|
|
148
148
|
- 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.
|
|
149
149
|
- 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.
|
|
150
|
-
- 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.
|
|
151
|
-
- Because of this, passing in a [`Sequence`](https://aidc-toolkit.com/api/Utility/classes/Sequence.html) is strongly recommended when creating multiple strings.
|
|
150
|
+
- If the value to create a string is numeric (`number` or `bigint`), the method uses a [`Transformer`](https://aidc-toolkit.com/v1.0/api/Utility/classes/Transformer.html) and supports sparse creation.
|
|
151
|
+
- Because of this, passing in a [`Sequence`](https://aidc-toolkit.com/v1.0/api/Utility/classes/Sequence.html) is strongly recommended when creating multiple strings.
|
|
152
152
|
|
|
153
153
|
#### Predefined Creators
|
|
154
154
|
|
|
155
155
|
The following creator types are predefined:
|
|
156
156
|
|
|
157
|
-
- [Character set](https://aidc-toolkit.com/api/Utility/classes/CharacterSetCreator.html)
|
|
157
|
+
- [Character set](https://aidc-toolkit.com/v1.0/api/Utility/classes/CharacterSetCreator.html)
|
|
158
158
|
- 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:
|
|
159
|
-
- [Numeric (0-9)](https://aidc-toolkit.com/api/Utility/variables/NUMERIC_CREATOR.html)
|
|
160
|
-
- [Hexadecimal (0-9, A-F)](https://aidc-toolkit.com/api/Utility/variables/HEXADECIMAL_CREATOR.html)
|
|
161
|
-
- [Alphabetic (A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHABETIC_CREATOR.html)
|
|
162
|
-
- [Alphanumeric (0-9, A-Z)](https://aidc-toolkit.com/api/Utility/variables/ALPHANUMERIC_CREATOR.html)
|
|
159
|
+
- [Numeric (0-9)](https://aidc-toolkit.com/v1.0/api/Utility/variables/NUMERIC_CREATOR.html)
|
|
160
|
+
- [Hexadecimal (0-9, A-F)](https://aidc-toolkit.com/v1.0/api/Utility/variables/HEXADECIMAL_CREATOR.html)
|
|
161
|
+
- [Alphabetic (A-Z)](https://aidc-toolkit.com/v1.0/api/Utility/variables/ALPHABETIC_CREATOR.html)
|
|
162
|
+
- [Alphanumeric (0-9, A-Z)](https://aidc-toolkit.com/v1.0/api/Utility/variables/ALPHANUMERIC_CREATOR.html)
|
|
163
163
|
|
|
164
164
|
#### Output Restriction
|
|
165
165
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/utility",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40-beta",
|
|
4
4
|
"description": "Foundational utilities for AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"test": "tsc --project tsconfig-test.json --noEmit && vitest run"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@aidc-toolkit/dev": "1.0.
|
|
32
|
+
"@aidc-toolkit/dev": "1.0.38-beta",
|
|
33
33
|
"vitest": "^4.0.18"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@aidc-toolkit/core": "1.0.
|
|
36
|
+
"@aidc-toolkit/core": "1.0.39-beta"
|
|
37
37
|
}
|
|
38
38
|
}
|