@nestia/e2e 8.0.2 → 8.0.5-dev.20250904
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/lib/TestValidator.d.ts +3 -3
- package/package.json +1 -1
- package/src/ArrayUtil.ts +320 -320
- 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/module.ts +7 -7
package/src/MapUtil.ts
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A namespace providing utility functions for Map manipulation.
|
|
3
|
-
*
|
|
4
|
-
* This namespace contains helper functions for working with JavaScript Map
|
|
5
|
-
* objects, providing convenient methods for common Map operations like
|
|
6
|
-
* retrieving values with lazy initialization.
|
|
7
|
-
*
|
|
8
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // Create a cache with lazy initialization
|
|
12
|
-
* const cache = new Map<string, ExpensiveObject>();
|
|
13
|
-
*
|
|
14
|
-
* const obj = MapUtil.take(cache, "key1", () => {
|
|
15
|
-
* console.log("Creating expensive object...");
|
|
16
|
-
* return new ExpensiveObject();
|
|
17
|
-
* });
|
|
18
|
-
*
|
|
19
|
-
* // Subsequent calls return cached value without re-creating
|
|
20
|
-
* const sameObj = MapUtil.take(cache, "key1", () => new ExpensiveObject());
|
|
21
|
-
* console.log(obj === sameObj); // true
|
|
22
|
-
* ```;
|
|
23
|
-
*/
|
|
24
|
-
export namespace MapUtil {
|
|
25
|
-
/**
|
|
26
|
-
* Retrieves a value from a Map or creates it using a lazy initialization
|
|
27
|
-
* function.
|
|
28
|
-
*
|
|
29
|
-
* This function implements the "get or create" pattern for Maps. If the key
|
|
30
|
-
* exists in the Map, it returns the existing value. Otherwise, it calls the
|
|
31
|
-
* provided factory function to create a new value, stores it in the Map, and
|
|
32
|
-
* returns it. The factory function is only called when the key doesn't exist,
|
|
33
|
-
* enabling lazy initialization and caching patterns.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* // Simple caching example
|
|
38
|
-
* const userCache = new Map<number, User>();
|
|
39
|
-
*
|
|
40
|
-
* const user = MapUtil.take(userCache, userId, () => {
|
|
41
|
-
* // This expensive operation only runs if userId is not cached
|
|
42
|
-
* return fetchUserFromDatabase(userId);
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* // Configuration object caching
|
|
46
|
-
* const configs = new Map<string, Config>();
|
|
47
|
-
*
|
|
48
|
-
* const dbConfig = MapUtil.take(configs, "database", () => ({
|
|
49
|
-
* host: "localhost",
|
|
50
|
-
* port: 5432,
|
|
51
|
-
* database: "myapp"
|
|
52
|
-
* }));
|
|
53
|
-
*
|
|
54
|
-
* // Lazy computation results
|
|
55
|
-
* const computationCache = new Map<string, number>();
|
|
56
|
-
*
|
|
57
|
-
* const result = MapUtil.take(computationCache, "fibonacci-40", () => {
|
|
58
|
-
* console.log("Computing fibonacci(40)...");
|
|
59
|
-
* return fibonacci(40); // Only computed once
|
|
60
|
-
* });
|
|
61
|
-
*
|
|
62
|
-
* // Using with complex keys
|
|
63
|
-
* const cache = new Map<[number, number], Matrix>();
|
|
64
|
-
* const key: [number, number] = [rows, cols];
|
|
65
|
-
*
|
|
66
|
-
* const matrix = MapUtil.take(cache, key, () =>
|
|
67
|
-
* generateIdentityMatrix(rows, cols)
|
|
68
|
-
* );
|
|
69
|
-
* ```;
|
|
70
|
-
*
|
|
71
|
-
* @template K - The type of keys in the Map
|
|
72
|
-
* @template V - The type of values in the Map
|
|
73
|
-
* @param map - The Map to retrieve from or update
|
|
74
|
-
* @param key - The key to look up in the Map
|
|
75
|
-
* @param value - A factory function that creates the value if key doesn't exist
|
|
76
|
-
* @returns The existing value if found, or the newly created value
|
|
77
|
-
*/
|
|
78
|
-
export function take<K, V>(map: Map<K, V>, key: K, value: () => V): V {
|
|
79
|
-
if (map.has(key)) {
|
|
80
|
-
return map.get(key) as V;
|
|
81
|
-
}
|
|
82
|
-
const newValue = value();
|
|
83
|
-
map.set(key, newValue);
|
|
84
|
-
return newValue;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* A namespace providing utility functions for Map manipulation.
|
|
3
|
+
*
|
|
4
|
+
* This namespace contains helper functions for working with JavaScript Map
|
|
5
|
+
* objects, providing convenient methods for common Map operations like
|
|
6
|
+
* retrieving values with lazy initialization.
|
|
7
|
+
*
|
|
8
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Create a cache with lazy initialization
|
|
12
|
+
* const cache = new Map<string, ExpensiveObject>();
|
|
13
|
+
*
|
|
14
|
+
* const obj = MapUtil.take(cache, "key1", () => {
|
|
15
|
+
* console.log("Creating expensive object...");
|
|
16
|
+
* return new ExpensiveObject();
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Subsequent calls return cached value without re-creating
|
|
20
|
+
* const sameObj = MapUtil.take(cache, "key1", () => new ExpensiveObject());
|
|
21
|
+
* console.log(obj === sameObj); // true
|
|
22
|
+
* ```;
|
|
23
|
+
*/
|
|
24
|
+
export namespace MapUtil {
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves a value from a Map or creates it using a lazy initialization
|
|
27
|
+
* function.
|
|
28
|
+
*
|
|
29
|
+
* This function implements the "get or create" pattern for Maps. If the key
|
|
30
|
+
* exists in the Map, it returns the existing value. Otherwise, it calls the
|
|
31
|
+
* provided factory function to create a new value, stores it in the Map, and
|
|
32
|
+
* returns it. The factory function is only called when the key doesn't exist,
|
|
33
|
+
* enabling lazy initialization and caching patterns.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Simple caching example
|
|
38
|
+
* const userCache = new Map<number, User>();
|
|
39
|
+
*
|
|
40
|
+
* const user = MapUtil.take(userCache, userId, () => {
|
|
41
|
+
* // This expensive operation only runs if userId is not cached
|
|
42
|
+
* return fetchUserFromDatabase(userId);
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* // Configuration object caching
|
|
46
|
+
* const configs = new Map<string, Config>();
|
|
47
|
+
*
|
|
48
|
+
* const dbConfig = MapUtil.take(configs, "database", () => ({
|
|
49
|
+
* host: "localhost",
|
|
50
|
+
* port: 5432,
|
|
51
|
+
* database: "myapp"
|
|
52
|
+
* }));
|
|
53
|
+
*
|
|
54
|
+
* // Lazy computation results
|
|
55
|
+
* const computationCache = new Map<string, number>();
|
|
56
|
+
*
|
|
57
|
+
* const result = MapUtil.take(computationCache, "fibonacci-40", () => {
|
|
58
|
+
* console.log("Computing fibonacci(40)...");
|
|
59
|
+
* return fibonacci(40); // Only computed once
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Using with complex keys
|
|
63
|
+
* const cache = new Map<[number, number], Matrix>();
|
|
64
|
+
* const key: [number, number] = [rows, cols];
|
|
65
|
+
*
|
|
66
|
+
* const matrix = MapUtil.take(cache, key, () =>
|
|
67
|
+
* generateIdentityMatrix(rows, cols)
|
|
68
|
+
* );
|
|
69
|
+
* ```;
|
|
70
|
+
*
|
|
71
|
+
* @template K - The type of keys in the Map
|
|
72
|
+
* @template V - The type of values in the Map
|
|
73
|
+
* @param map - The Map to retrieve from or update
|
|
74
|
+
* @param key - The key to look up in the Map
|
|
75
|
+
* @param value - A factory function that creates the value if key doesn't exist
|
|
76
|
+
* @returns The existing value if found, or the newly created value
|
|
77
|
+
*/
|
|
78
|
+
export function take<K, V>(map: Map<K, V>, key: K, value: () => V): V {
|
|
79
|
+
if (map.has(key)) {
|
|
80
|
+
return map.get(key) as V;
|
|
81
|
+
}
|
|
82
|
+
const newValue = value();
|
|
83
|
+
map.set(key, newValue);
|
|
84
|
+
return newValue;
|
|
85
|
+
}
|
|
86
|
+
}
|