@nestia/e2e 10.0.2 → 11.0.0-dev.20260305
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/LICENSE +21 -21
- package/README.md +93 -93
- package/package.json +19 -21
- package/src/ArrayUtil.ts +320 -320
- package/src/DynamicExecutor.ts +274 -274
- package/src/GaffComparator.ts +287 -287
- package/src/MapUtil.ts +86 -86
- package/src/RandomGenerator.ts +490 -490
- package/src/TestValidator.ts +635 -635
- package/src/index.ts +4 -4
- package/src/internal/json_equal_to.ts +35 -35
- package/src/module.ts +7 -7
- package/lib/ArrayUtil.d.ts +0 -244
- package/lib/ArrayUtil.js +0 -410
- package/lib/ArrayUtil.js.map +0 -1
- package/lib/DynamicExecutor.d.ts +0 -144
- package/lib/DynamicExecutor.js +0 -373
- package/lib/DynamicExecutor.js.map +0 -1
- package/lib/GaffComparator.d.ts +0 -255
- package/lib/GaffComparator.js +0 -286
- package/lib/GaffComparator.js.map +0 -1
- package/lib/MapUtil.d.ts +0 -79
- package/lib/MapUtil.js +0 -92
- package/lib/MapUtil.js.map +0 -1
- package/lib/RandomGenerator.d.ts +0 -416
- package/lib/RandomGenerator.js +0 -480
- package/lib/RandomGenerator.js.map +0 -1
- package/lib/TestValidator.d.ts +0 -389
- package/lib/TestValidator.js +0 -643
- package/lib/TestValidator.js.map +0 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -42
- package/lib/index.js.map +0 -1
- package/lib/internal/json_equal_to.d.ts +0 -1
- package/lib/internal/json_equal_to.js +0 -51
- package/lib/internal/json_equal_to.js.map +0 -1
- package/lib/module.d.ts +0 -6
- package/lib/module.js +0 -23
- package/lib/module.js.map +0 -1
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as e2e from "./module";
|
|
2
|
-
|
|
3
|
-
export default e2e;
|
|
4
|
-
export * from "./module";
|
|
1
|
+
import * as e2e from "./module";
|
|
2
|
+
|
|
3
|
+
export default e2e;
|
|
4
|
+
export * from "./module";
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
export const json_equal_to =
|
|
2
|
-
(exception: (key: string) => boolean) =>
|
|
3
|
-
<T>(x: T) =>
|
|
4
|
-
(y: T | null | undefined): string[] => {
|
|
5
|
-
const container: string[] = [];
|
|
6
|
-
const iterate =
|
|
7
|
-
(accessor: string) =>
|
|
8
|
-
(x: any) =>
|
|
9
|
-
(y: any): void => {
|
|
10
|
-
if (typeof x === "function" || typeof y === "function") return;
|
|
11
|
-
else if (typeof x !== typeof y) container.push(accessor);
|
|
12
|
-
else if (x instanceof Array)
|
|
13
|
-
if (!(y instanceof Array)) container.push(accessor);
|
|
14
|
-
else array(accessor)(x)(y);
|
|
15
|
-
else if (x instanceof Object) object(accessor)(x)(y);
|
|
16
|
-
else if (x !== y) container.push(accessor);
|
|
17
|
-
};
|
|
18
|
-
const array =
|
|
19
|
-
(accessor: string) =>
|
|
20
|
-
(x: any[]) =>
|
|
21
|
-
(y: any[]): void => {
|
|
22
|
-
if (x.length !== y.length) container.push(`${accessor}.length`);
|
|
23
|
-
x.forEach((xItem, i) => iterate(`${accessor}[${i}]`)(xItem)(y[i]));
|
|
24
|
-
};
|
|
25
|
-
const object =
|
|
26
|
-
(accessor: string) =>
|
|
27
|
-
(x: any) =>
|
|
28
|
-
(y: any): void =>
|
|
29
|
-
Object.keys(x)
|
|
30
|
-
.filter((key) => x[key] !== undefined && !exception(key))
|
|
31
|
-
.forEach((key) => iterate(`${accessor}.${key}`)(x[key])(y[key]));
|
|
32
|
-
|
|
33
|
-
iterate("")(x)(y);
|
|
34
|
-
return container;
|
|
35
|
-
};
|
|
1
|
+
export const json_equal_to =
|
|
2
|
+
(exception: (key: string) => boolean) =>
|
|
3
|
+
<T>(x: T) =>
|
|
4
|
+
(y: T | null | undefined): string[] => {
|
|
5
|
+
const container: string[] = [];
|
|
6
|
+
const iterate =
|
|
7
|
+
(accessor: string) =>
|
|
8
|
+
(x: any) =>
|
|
9
|
+
(y: any): void => {
|
|
10
|
+
if (typeof x === "function" || typeof y === "function") return;
|
|
11
|
+
else if (typeof x !== typeof y) container.push(accessor);
|
|
12
|
+
else if (x instanceof Array)
|
|
13
|
+
if (!(y instanceof Array)) container.push(accessor);
|
|
14
|
+
else array(accessor)(x)(y);
|
|
15
|
+
else if (x instanceof Object) object(accessor)(x)(y);
|
|
16
|
+
else if (x !== y) container.push(accessor);
|
|
17
|
+
};
|
|
18
|
+
const array =
|
|
19
|
+
(accessor: string) =>
|
|
20
|
+
(x: any[]) =>
|
|
21
|
+
(y: any[]): void => {
|
|
22
|
+
if (x.length !== y.length) container.push(`${accessor}.length`);
|
|
23
|
+
x.forEach((xItem, i) => iterate(`${accessor}[${i}]`)(xItem)(y[i]));
|
|
24
|
+
};
|
|
25
|
+
const object =
|
|
26
|
+
(accessor: string) =>
|
|
27
|
+
(x: any) =>
|
|
28
|
+
(y: any): void =>
|
|
29
|
+
Object.keys(x)
|
|
30
|
+
.filter((key) => x[key] !== undefined && !exception(key))
|
|
31
|
+
.forEach((key) => iterate(`${accessor}.${key}`)(x[key])(y[key]));
|
|
32
|
+
|
|
33
|
+
iterate("")(x)(y);
|
|
34
|
+
return container;
|
|
35
|
+
};
|
package/src/module.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./ArrayUtil";
|
|
2
|
-
export * from "./MapUtil";
|
|
3
|
-
export * from "./RandomGenerator";
|
|
4
|
-
|
|
5
|
-
export * from "./DynamicExecutor";
|
|
6
|
-
export * from "./GaffComparator";
|
|
7
|
-
export * from "./TestValidator";
|
|
1
|
+
export * from "./ArrayUtil";
|
|
2
|
+
export * from "./MapUtil";
|
|
3
|
+
export * from "./RandomGenerator";
|
|
4
|
+
|
|
5
|
+
export * from "./DynamicExecutor";
|
|
6
|
+
export * from "./GaffComparator";
|
|
7
|
+
export * from "./TestValidator";
|
package/lib/ArrayUtil.d.ts
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A namespace providing utility functions for array manipulation.
|
|
3
|
-
*
|
|
4
|
-
* This namespace contains utility functions for array operations including
|
|
5
|
-
* asynchronous processing, filtering, mapping, and repetition tasks implemented
|
|
6
|
-
* in functional programming style. Functions use direct parameter passing for
|
|
7
|
-
* simplicity while maintaining functional programming principles.
|
|
8
|
-
*
|
|
9
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* // Asynchronous filtering example
|
|
13
|
-
* const numbers = [1, 2, 3, 4, 5];
|
|
14
|
-
* const evenNumbers = await ArrayUtil.asyncFilter(numbers,
|
|
15
|
-
* async (num) => num % 2 === 0
|
|
16
|
-
* );
|
|
17
|
-
* console.log(evenNumbers); // [2, 4]
|
|
18
|
-
* ```;
|
|
19
|
-
*/
|
|
20
|
-
export declare namespace ArrayUtil {
|
|
21
|
-
/**
|
|
22
|
-
* Filters an array by applying an asynchronous predicate function to each
|
|
23
|
-
* element.
|
|
24
|
-
*
|
|
25
|
-
* Elements are processed sequentially, ensuring order is maintained. The
|
|
26
|
-
* predicate function receives the element, index, and the full array as
|
|
27
|
-
* parameters.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```typescript
|
|
31
|
-
* const users = [
|
|
32
|
-
* { id: 1, name: 'Alice', active: true },
|
|
33
|
-
* { id: 2, name: 'Bob', active: false },
|
|
34
|
-
* { id: 3, name: 'Charlie', active: true }
|
|
35
|
-
* ];
|
|
36
|
-
*
|
|
37
|
-
* const activeUsers = await ArrayUtil.asyncFilter(users,
|
|
38
|
-
* async (user) => {
|
|
39
|
-
* // Async validation logic (e.g., API call)
|
|
40
|
-
* await new Promise(resolve => setTimeout(resolve, 100));
|
|
41
|
-
* return user.active;
|
|
42
|
-
* }
|
|
43
|
-
* );
|
|
44
|
-
* console.log(activeUsers); // [{ id: 1, name: 'Alice', active: true }, { id: 3, name: 'Charlie', active: true }]
|
|
45
|
-
* ```;
|
|
46
|
-
*
|
|
47
|
-
* @template Input - The type of elements in the input array
|
|
48
|
-
* @param elements - The readonly array to filter
|
|
49
|
-
* @param pred - The asynchronous predicate function to test each element
|
|
50
|
-
* @returns A Promise resolving to the filtered array
|
|
51
|
-
*/
|
|
52
|
-
const asyncFilter: <Input>(elements: readonly Input[], pred: (elem: Input, index: number, array: readonly Input[]) => Promise<boolean>) => Promise<Input[]>;
|
|
53
|
-
/**
|
|
54
|
-
* Executes an asynchronous function for each element in an array
|
|
55
|
-
* sequentially.
|
|
56
|
-
*
|
|
57
|
-
* Unlike JavaScript's native forEach, this function processes asynchronous
|
|
58
|
-
* functions sequentially and waits for all operations to complete. It
|
|
59
|
-
* performs sequential processing rather than parallel processing, making it
|
|
60
|
-
* suitable for operations where order matters.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* const urls = ['url1', 'url2', 'url3'];
|
|
65
|
-
*
|
|
66
|
-
* await ArrayUtil.asyncForEach(urls, async (url, index) => {
|
|
67
|
-
* console.log(`Processing ${index}: ${url}`);
|
|
68
|
-
* const data = await fetch(url);
|
|
69
|
-
* await processData(data);
|
|
70
|
-
* console.log(`Completed ${index}: ${url}`);
|
|
71
|
-
* });
|
|
72
|
-
* console.log('All URLs processed sequentially');
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @template Input - The type of elements in the input array
|
|
76
|
-
* @param elements - The readonly array to process
|
|
77
|
-
* @param closure - The asynchronous function to execute for each element
|
|
78
|
-
* @returns A Promise<void> that resolves when all operations complete
|
|
79
|
-
*/
|
|
80
|
-
const asyncForEach: <Input>(elements: readonly Input[], closure: (elem: Input, index: number, array: readonly Input[]) => Promise<any>) => Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* Transforms each element of an array using an asynchronous function to
|
|
83
|
-
* create a new array.
|
|
84
|
-
*
|
|
85
|
-
* Similar to JavaScript's native map but processes asynchronous functions
|
|
86
|
-
* sequentially. Each element's transformation is completed before proceeding
|
|
87
|
-
* to the next element, ensuring order is maintained. This function still
|
|
88
|
-
* maintains the currying pattern for composition.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```typescript
|
|
92
|
-
* const userIds = [1, 2, 3, 4, 5];
|
|
93
|
-
*
|
|
94
|
-
* const userDetails = await ArrayUtil.asyncMap(userIds)(
|
|
95
|
-
* async (id, index) => {
|
|
96
|
-
* console.log(`Fetching user ${id} (${index + 1}/${userIds.length})`);
|
|
97
|
-
* const response = await fetch(`/api/users/${id}`);
|
|
98
|
-
* return await response.json();
|
|
99
|
-
* }
|
|
100
|
-
* );
|
|
101
|
-
* console.log('All users fetched:', userDetails);
|
|
102
|
-
* ```
|
|
103
|
-
*
|
|
104
|
-
* @template Input - The type of elements in the input array
|
|
105
|
-
* @param elements - The readonly array to transform
|
|
106
|
-
* @returns A function that takes a transformation function and returns a
|
|
107
|
-
* Promise resolving to the transformed array
|
|
108
|
-
*/
|
|
109
|
-
const asyncMap: <Input, Output>(elements: readonly Input[], closure: (elem: Input, index: number, array: readonly Input[]) => Promise<Output>) => Promise<Output[]>;
|
|
110
|
-
/**
|
|
111
|
-
* Executes an asynchronous function a specified number of times sequentially.
|
|
112
|
-
*
|
|
113
|
-
* Executes the function with indices from 0 to count-1 incrementally. Each
|
|
114
|
-
* execution is performed sequentially, and all results are collected into an
|
|
115
|
-
* array.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* // Generate random data 5 times
|
|
120
|
-
* const randomData = await ArrayUtil.asyncRepeat(5, async (index) => {
|
|
121
|
-
* await new Promise(resolve => setTimeout(resolve, 100)); // Wait 0.1 seconds
|
|
122
|
-
* return {
|
|
123
|
-
* id: index,
|
|
124
|
-
* value: Math.random(),
|
|
125
|
-
* timestamp: new Date().toISOString()
|
|
126
|
-
* };
|
|
127
|
-
* });
|
|
128
|
-
* console.log('Generated data:', randomData);
|
|
129
|
-
* ```;
|
|
130
|
-
*
|
|
131
|
-
* @template T - The type of the result from each execution
|
|
132
|
-
* @param count - The number of times to repeat (non-negative integer)
|
|
133
|
-
* @param closure - The asynchronous function to execute repeatedly
|
|
134
|
-
* @returns A Promise resolving to an array of results
|
|
135
|
-
*/
|
|
136
|
-
const asyncRepeat: <T>(count: number, closure: (index: number) => Promise<T>) => Promise<T[]>;
|
|
137
|
-
/**
|
|
138
|
-
* Checks if at least one element in the array satisfies the given condition.
|
|
139
|
-
*
|
|
140
|
-
* Similar to JavaScript's native some() method. Returns true immediately when
|
|
141
|
-
* the first element satisfying the condition is found.
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* ```typescript
|
|
145
|
-
* const numbers = [1, 3, 5, 7, 8, 9];
|
|
146
|
-
* const products = [
|
|
147
|
-
* { name: 'Apple', price: 100, inStock: true },
|
|
148
|
-
* { name: 'Banana', price: 50, inStock: false },
|
|
149
|
-
* { name: 'Orange', price: 80, inStock: true }
|
|
150
|
-
* ];
|
|
151
|
-
*
|
|
152
|
-
* const hasEvenNumber = ArrayUtil.has(numbers, num => num % 2 === 0);
|
|
153
|
-
* console.log(hasEvenNumber); // true (8 exists)
|
|
154
|
-
*
|
|
155
|
-
* const hasExpensiveItem = ArrayUtil.has(products, product => product.price > 90);
|
|
156
|
-
* console.log(hasExpensiveItem); // true (Apple costs 100)
|
|
157
|
-
*
|
|
158
|
-
* const hasOutOfStock = ArrayUtil.has(products, product => !product.inStock);
|
|
159
|
-
* console.log(hasOutOfStock); // true (Banana is out of stock)
|
|
160
|
-
* ```;
|
|
161
|
-
*
|
|
162
|
-
* @template T - The type of elements in the array
|
|
163
|
-
* @param elements - The readonly array to check
|
|
164
|
-
* @param pred - The predicate function to test elements
|
|
165
|
-
* @returns Boolean indicating if any element satisfies the condition
|
|
166
|
-
*/
|
|
167
|
-
const has: <T>(elements: readonly T[], pred: (elem: T) => boolean) => boolean;
|
|
168
|
-
/**
|
|
169
|
-
* Executes a function a specified number of times and collects the results
|
|
170
|
-
* into an array.
|
|
171
|
-
*
|
|
172
|
-
* A synchronous repetition function that executes the given function for each
|
|
173
|
-
* index (from 0 to count-1) and collects the results into an array.
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```typescript
|
|
177
|
-
* // Generate an array of squares from 1 to 5
|
|
178
|
-
* const squares = ArrayUtil.repeat(5, index => (index + 1) ** 2);
|
|
179
|
-
* console.log(squares); // [1, 4, 9, 16, 25]
|
|
180
|
-
*
|
|
181
|
-
* // Generate an array of default user objects
|
|
182
|
-
* const users = ArrayUtil.repeat(3, index => ({
|
|
183
|
-
* id: index + 1,
|
|
184
|
-
* name: `User${index + 1}`,
|
|
185
|
-
* email: `user${index + 1}@example.com`
|
|
186
|
-
* }));
|
|
187
|
-
* console.log(users);
|
|
188
|
-
* // [
|
|
189
|
-
* // { id: 1, name: 'User1', email: 'user1@example.com' },
|
|
190
|
-
* // { id: 2, name: 'User2', email: 'user2@example.com' },
|
|
191
|
-
* // { id: 3, name: 'User3', email: 'user3@example.com' }
|
|
192
|
-
* // ]
|
|
193
|
-
* ```
|
|
194
|
-
*
|
|
195
|
-
* @template T - The type of the result from each execution
|
|
196
|
-
* @param count - The number of times to repeat (non-negative integer)
|
|
197
|
-
* @param closure - The function to execute repeatedly
|
|
198
|
-
* @returns An array of results
|
|
199
|
-
*/
|
|
200
|
-
const repeat: <T>(count: number, closure: (index: number) => T) => T[];
|
|
201
|
-
/**
|
|
202
|
-
* Generates all possible subsets of a given array.
|
|
203
|
-
*
|
|
204
|
-
* Implements the mathematical concept of power set, generating 2^n subsets
|
|
205
|
-
* from an array of n elements. Uses depth-first search (DFS) algorithm to
|
|
206
|
-
* calculate all possible combinations of including or excluding each
|
|
207
|
-
* element.
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* ```typescript
|
|
211
|
-
* const numbers = [1, 2, 3];
|
|
212
|
-
* const allSubsets = ArrayUtil.subsets(numbers);
|
|
213
|
-
* console.log(allSubsets);
|
|
214
|
-
* // [
|
|
215
|
-
* // [], // empty set
|
|
216
|
-
* // [3], // {3}
|
|
217
|
-
* // [2], // {2}
|
|
218
|
-
* // [2, 3], // {2, 3}
|
|
219
|
-
* // [1], // {1}
|
|
220
|
-
* // [1, 3], // {1, 3}
|
|
221
|
-
* // [1, 2], // {1, 2}
|
|
222
|
-
* // [1, 2, 3] // {1, 2, 3}
|
|
223
|
-
* // ]
|
|
224
|
-
*
|
|
225
|
-
* const colors = ['red', 'blue'];
|
|
226
|
-
* const colorSubsets = ArrayUtil.subsets(colors);
|
|
227
|
-
* console.log(colorSubsets);
|
|
228
|
-
* // [
|
|
229
|
-
* // [],
|
|
230
|
-
* // ['blue'],
|
|
231
|
-
* // ['red'],
|
|
232
|
-
* // ['red', 'blue']
|
|
233
|
-
* // ]
|
|
234
|
-
*
|
|
235
|
-
* // Warning: Result size grows exponentially with array size
|
|
236
|
-
* // Example: 10 elements → 1,024 subsets, 20 elements → 1,048,576 subsets
|
|
237
|
-
* ```;
|
|
238
|
-
*
|
|
239
|
-
* @template T - The type of elements in the array
|
|
240
|
-
* @param array - The array to generate subsets from
|
|
241
|
-
* @returns An array containing all possible subsets
|
|
242
|
-
*/
|
|
243
|
-
const subsets: <T>(array: T[]) => T[][];
|
|
244
|
-
}
|