@aidc-toolkit/utility 0.9.18-beta → 0.9.20-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 CHANGED
@@ -2,25 +2,169 @@
2
2
 
3
3
  **Copyright © 2024-2025 Dolphin Data Development Ltd. and AIDC Toolkit contributors**
4
4
 
5
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
6
- License. You may obtain a copy of the License at
5
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
7
6
 
8
- https://www.apache.org/licenses/LICENSE-2.0
7
+ https://www.apache.org/licenses/LICENSE-2.0
9
8
 
10
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
11
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
9
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
12
10
 
13
11
  ## Overview
14
12
 
15
- ⚠️ **This software is in beta**, with production release is scheduled for 2024Q4. To follow the status of that and other
16
- projects, go to the AIDC Toolkit [projects](https://github.com/orgs/aidc-toolkit/projects) page.
13
+ > [!WARNING]
14
+ >
15
+ > **This software is in beta**, with production release is scheduled for 2025Q4. To follow the status of this and other projects, go to the AIDC Toolkit [projects](https://github.com/orgs/aidc-toolkit/projects) page.
17
16
 
18
- The AIDC Toolkit `utility` package provides functionality that is not specific to AIDC but is nevertheless required by
19
- other AIDC Toolkit packages:
17
+ The AIDC Toolkit `utility` package provides classes to manipulate integers and strings, independently of any AIDC problem domain. The package has been designed to maximize performance and minimize memory by reducing many of the typical AIDC requirements, such as serial number generation, to on-demand generation using the JavaScript [`Generator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator) type.
20
18
 
21
- - Number transformation
22
- - String validation
23
- - String creation
19
+ To provide the most flexibility and to handle the most significant demands of the AIDC problem domain, the AIDC Toolkit uses the JavaScript `bigint` type, with many functions converting from the lower-range `number` type if provided. This gives applications significant flexibility at a small performance cost inherent in `bigint` operations.
24
20
 
25
- A comprehensive overview of this package may be found in the [AIDC Toolkit
26
- documentation](https://aidc-toolkit.github.io).
21
+ ## Integers
22
+
23
+ ### Sequence
24
+
25
+ Many of AIDC processes can be reduced to a simple statement about sequences:
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."
30
+
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
+
33
+ > [!TIP]
34
+ >
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
+
37
+ #### Creating and using a sequence
38
+
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
+ ```typescript
41
+ // Sequence starts at 33,000 and will iterate 1,000 times.
42
+ const sequence = new Sequence(33000, 1000);
43
+ ```
44
+ 1. Use the sequence.
45
+ * Use it in a for loop.
46
+ ```typescript
47
+ for (const value of sequence) {
48
+ console.log(value);
49
+ }
50
+ ```
51
+ * Transform it using an `Iterator` helper method.
52
+ ```typescript
53
+ const sum = Iterator.from(sequence).reduce((accumulator, value) => accumulator + value, 0);
54
+ ```
55
+ * Pass it to a function.
56
+ ```typescript
57
+ // Crate a sequence of 10-character hexadecimal strings.
58
+ const stringSequence = HEXADECIMAL_STRING_CREATOR.create(10, sequence);
59
+ ```
60
+
61
+ ### Transformer
62
+
63
+ A transformer transforms values in a numeric domain to values in a range equal to the domain or to another range defined by a callback function.
64
+
65
+ There are two types of transformers defined in the AIDC Toolkit: the identity transformer and the encryption transformer. Regardless of the type, before any input value is transformed, it is validated against the domain provided when constructing the transformer; if the input value is less than zero or greater than or equal to the domain, an error is thrown.
66
+
67
+ The identity transformer simply maps any input value to itself as the output value.
68
+
69
+ The encryption transformer maps an input value to an output value resulting from repeated shuffle and xor operations defined by a tweak. In cryptography, a tweak is a value that alters an operation to change or "tweak" the output in a predictable and unique way that is hard to reverse engineer. Normally, a tweak works side by side with a password to generate a cryptographic key to ensure that no two systems can produce the same output from the same input and password; each system defines its own tweak and the password is kept by the user. Because the tweak is applied to every encryption operation, it is inherently less secure (e.g., a system administrator may know the tweak but that's not enough to compromise any user's encryption), but for the purposes of the AIDC Toolkit, it is secure enough.
70
+
71
+ Suppose that you're manufacturing a product that is valuable enough to be of interest to counterfeiters. To protect the product, you want to generate a unique serial number for each one you put on the market. If anyone submits a warranty claim, the serial number will tell you whether the product is legitimate.
72
+
73
+ You expect that you will manufacture at most 1,000,000 units of the product before releasing an upgrade, so your serial numbers are going to be numeric only and 6 digits long. If you generate the serial numbers in sequence, then generating 10 of them starting from unit 200,000 results in the following: 200000, 200001, 200002, 200003, 200004, 200005, 200006, 200007, 200008, 200009.
74
+
75
+ ```typescript
76
+ // Transformer has a domain of 1,000,000; no tweak means that the identity transformer is used.
77
+ for (const value of Transformer.get(1000000).forward(new Sequence(200000, 10))) {
78
+ console.log(value);
79
+ }
80
+ ```
81
+
82
+ The sequence is predictable and a counterfeiter can easily guess at valid serial numbers, which will cause problems for distributors and retailers when they see duplicates in the supply chain, problems for your customers who believe they are buying a legitimate product, and problems for you when you can't easily distinguish legitimate from counterfeit.
83
+
84
+ The first thing you need to do is put some space between your serial numbers, to make guessing difficult. Let's say that in this case you make serial numbers 8 digits long, which means you have 100 times the capacity of serial numbers as of your expected manufacturing run. Next, you use the encryption transformer, with the tweak set to some random value (which you have to save and reuse to ensure that you don't generate any duplicates). Generating 10 serial numbers starting from unit 200,000 results in the following: 14608575, 00118914, 14609085, 00250498, 07625339, 85755635, 41179259, 67532896, 02000912, 19087354.
85
+
86
+ ```typescript
87
+ // Transformer has a domain of 100,000,000; tweak means that the encryption transformer is used.
88
+ for (const value of Transformer.get(100000000, 8675309).forward(new Sequence(200000, 10))) {
89
+ console.log(value);
90
+ }
91
+ ```
92
+
93
+ The sequence is statistically random and a counterfeiter is highly unlikely to guess at valid serial numbers, which will make detection of illegitimate serial numbers significantly easier for all parties.
94
+
95
+ ### Sequence and Transformer
96
+
97
+ 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.
98
+
99
+ 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.
100
+
101
+ ```mermaid
102
+ flowchart TD
103
+ ValueOrValuesType{"Value(s) type"}
104
+ ValueOrValuesType -->|Single value| ValidateSingleValue{{Validate value}}
105
+ ValidateSingleValue --> ProcessSingleValue[[Process value]]
106
+ ProcessSingleValue --> Return["Return result(s)"]
107
+ ValueOrValuesType -->|Iterable| IterableType{Iterable type}
108
+ IterableType -->|Sequence| ValidateMinimumValue{{Validate minimum value}}
109
+ ValidateMinimumValue --> ValidateMaximumValue{{Validate maximum value}}
110
+ ValidateMaximumValue --> ForEachSequenceValue[/For each value\]
111
+ ForEachSequenceValue --> ProcessSequenceValue[[Process value]]
112
+ ProcessSequenceValue --> NextSequenceValue[\Next/]
113
+ NextSequenceValue -->|Not done| ProcessSequenceValue
114
+ NextSequenceValue -->|Done| Return
115
+ IterableType -->|Not Sequence| ForEachIterableValue[/For each value\]
116
+ ForEachIterableValue --> ValidateIterableValue{{Validate value}}
117
+ ValidateIterableValue --> ProcessIterableValue[[Process value]]
118
+ ProcessIterableValue --> NextIterableValue[\Next/]
119
+ NextIterableValue -->|Not done| ValidateIterableValue
120
+ NextIterableValue -->|Done| Return
121
+ ```
122
+
123
+ ## Strings
124
+
125
+ ### String validation
126
+
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
+
129
+ 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.
130
+
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
+
133
+ #### Predefined validators
134
+
135
+ The following validator types are predefined:
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)
147
+
148
+ ### String creation
149
+
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
+
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
+
157
+ #### Predefined creators
158
+
159
+ The following creator types are predefined:
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)
167
+
168
+ #### Output restriction
169
+
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).
@@ -1,4 +1,4 @@
1
- import type { IndexedCallback } from "./iterable-utility";
1
+ import type { IndexedCallback } from "./iterable-utility.js";
2
2
  import type { StringValidation, StringValidator } from "./string.js";
3
3
  import { type TransformerInput, type TransformerOutput } from "./transformer.js";
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"character-set.d.ts","sourceRoot":"","sources":["../src/character-set.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAe,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE9F;;GAEG;AACH,oBAAY,SAAS;IACjB;;OAEG;IACH,IAAI,IAAA;IAEJ;;OAEG;IACH,SAAS,IAAA;IAET;;OAEG;IACH,UAAU,IAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC5D;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAElC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC;CACnD;AAED;;GAEG;AACH,qBAAa,qBAAsB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;AAElF;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAG7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAyB,qBAAqB,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,qBAIY,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAA2B,qBAAqB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { type I18NEnvironment } from "@aidc-toolkit/core";
1
+ import { type I18nEnvironment } from "@aidc-toolkit/core";
2
2
  import { type i18n, type Resource } from "i18next";
3
3
  import { localeStrings as enLocaleStrings } from "./en/locale-strings.js";
4
4
  export declare const utilityNS = "aidct_utility";
@@ -23,5 +23,5 @@ export declare const i18nextUtility: i18n;
23
23
  * @returns
24
24
  * Void promise.
25
25
  */
26
- export declare function i18nUtilityInit(environment: I18NEnvironment, debug?: boolean): Promise<void>;
26
+ export declare function i18nUtilityInit(environment: I18nEnvironment, debug?: boolean): Promise<void>;
27
27
  //# sourceMappingURL=i18n.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/utility",
3
- "version": "0.9.18-beta",
3
+ "version": "0.9.20-beta",
4
4
  "description": "Foundational utilities for AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -27,11 +27,11 @@
27
27
  "test": "vitest run"
28
28
  },
29
29
  "devDependencies": {
30
- "@aidc-toolkit/dev": "^0.9.18-beta",
31
- "vitest": "^3.2.2"
30
+ "@aidc-toolkit/dev": "beta",
31
+ "vitest": "^4.0.13"
32
32
  },
33
33
  "dependencies": {
34
- "@aidc-toolkit/core": "^0.9.18-beta",
35
- "i18next": "^25.2.1"
34
+ "@aidc-toolkit/core": "beta",
35
+ "i18next": "^25.6.3"
36
36
  }
37
37
  }
@@ -1,4 +1,4 @@
1
- import type { IndexedCallback } from "./iterable-utility";
1
+ import type { IndexedCallback } from "./iterable-utility.js";
2
2
  import { i18nextUtility } from "./locale/i18n.js";
3
3
  import { RegExpValidator } from "./reg-exp.js";
4
4
  import type { StringValidation, StringValidator } from "./string.js";
@@ -1,4 +1,4 @@
1
- import { i18nAssertValidResources, i18nCoreInit, type I18NEnvironment } from "@aidc-toolkit/core";
1
+ import { i18nAssertValidResources, i18nCoreInit, type I18nEnvironment } from "@aidc-toolkit/core";
2
2
  import i18next, { type i18n, type Resource } from "i18next";
3
3
  import { localeStrings as enLocaleStrings } from "./en/locale-strings.js";
4
4
  import { localeStrings as frLocaleStrings } from "./fr/locale-strings.js";
@@ -39,6 +39,6 @@ export const i18nextUtility: i18n = i18next.createInstance();
39
39
  * @returns
40
40
  * Void promise.
41
41
  */
42
- export async function i18nUtilityInit(environment: I18NEnvironment, debug = false): Promise<void> {
42
+ export async function i18nUtilityInit(environment: I18nEnvironment, debug = false): Promise<void> {
43
43
  await i18nCoreInit(i18nextUtility, environment, debug, utilityNS, utilityResources);
44
44
  }
@@ -1,4 +1,4 @@
1
- import { I18NEnvironment } from "@aidc-toolkit/core";
1
+ import { I18nEnvironment } from "@aidc-toolkit/core";
2
2
  import { describe, expect, test } from "vitest";
3
3
  import {
4
4
  ALPHABETIC_CREATOR, ALPHABETIC_VALIDATOR,
@@ -11,7 +11,7 @@ import {
11
11
  Sequence
12
12
  } from "../src";
13
13
 
14
- await i18nUtilityInit(I18NEnvironment.CLI);
14
+ await i18nUtilityInit(I18nEnvironment.CLI);
15
15
 
16
16
  // Type is used to ensure that testCharacterSet() is not called with creator twice.
17
17
  type ValidatorNotCreator<T extends CharacterSetValidator> = T extends CharacterSetCreator ? never : T;
@@ -1,8 +1,8 @@
1
- import { I18NEnvironment } from "@aidc-toolkit/core";
1
+ import { I18nEnvironment } from "@aidc-toolkit/core";
2
2
  import { describe, expect, test } from "vitest";
3
3
  import { i18nUtilityInit, RecordValidator } from "../src";
4
4
 
5
- await i18nUtilityInit(I18NEnvironment.CLI);
5
+ await i18nUtilityInit(I18nEnvironment.CLI);
6
6
 
7
7
  describe("Record validator", () => {
8
8
  enum StringEnum {
@@ -1,8 +1,8 @@
1
- import { I18NEnvironment } from "@aidc-toolkit/core";
1
+ import { I18nEnvironment } from "@aidc-toolkit/core";
2
2
  import { describe, expect, test } from "vitest";
3
3
  import { i18nUtilityInit, RegExpValidator } from "../src";
4
4
 
5
- await i18nUtilityInit(I18NEnvironment.CLI);
5
+ await i18nUtilityInit(I18nEnvironment.CLI);
6
6
 
7
7
  describe("Regular expression validator", () => {
8
8
  test("Validation", () => {
@@ -1,8 +1,8 @@
1
- import { I18NEnvironment } from "@aidc-toolkit/core";
1
+ import { I18nEnvironment } from "@aidc-toolkit/core";
2
2
  import { describe, expect, test } from "vitest";
3
3
  import { i18nUtilityInit, Sequence } from "../src";
4
4
 
5
- await i18nUtilityInit(I18NEnvironment.CLI);
5
+ await i18nUtilityInit(I18nEnvironment.CLI);
6
6
 
7
7
  describe("Sequence", () => {
8
8
  const sequence1 = new Sequence(10, 20);
@@ -1,8 +1,8 @@
1
- import { I18NEnvironment } from "@aidc-toolkit/core";
2
- import { afterEach, describe, expect, test } from "vitest";
1
+ import { I18nEnvironment } from "@aidc-toolkit/core";
2
+ import { describe, expect, test } from "vitest";
3
3
  import { EncryptionTransformer, i18nUtilityInit, IdentityTransformer, Sequence, Transformer } from "../src";
4
4
 
5
- await i18nUtilityInit(I18NEnvironment.CLI);
5
+ await i18nUtilityInit(I18nEnvironment.CLI);
6
6
 
7
7
  function testTransformer(domain: number, tweak?: number, callback?: (value: bigint, forwardValue: bigint) => void): void {
8
8
  const transformer = Transformer.get(domain, tweak);
@@ -52,12 +52,6 @@ function testTransformer(domain: number, tweak?: number, callback?: (value: bigi
52
52
  expect(() => transformer.forward(new Sequence(-1, -1))).toThrow("Minimum value -1 must be greater than or equal to 0");
53
53
  }
54
54
 
55
- // TODO Remove when https://github.com/vitest-dev/vitest/discussions/6511 resolved.
56
- afterEach(async () => {
57
- // eslint-disable-next-line promise/avoid-new -- Patch.
58
- await new Promise(resolve => setImmediate(resolve));
59
- });
60
-
61
55
  describe("Identity", () => {
62
56
  test("Get", () => {
63
57
  const transformer = Transformer.get(1000);