@catbee/utils 0.0.6 → 0.0.8-next.0
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 +1 -1
- package/README.md +77 -1107
- package/build/index.cjs +6888 -0
- package/build/index.d.ts +5242 -0
- package/build/index.mjs +6615 -0
- package/package.json +26 -95
- package/build/esm/config.d.ts +0 -130
- package/build/esm/config.js +0 -145
- package/build/esm/config.js.map +0 -1
- package/build/esm/index.d.ts +0 -27
- package/build/esm/index.js +0 -50
- package/build/esm/index.js.map +0 -1
- package/build/esm/servers/server.builder.d.ts +0 -625
- package/build/esm/servers/server.builder.js +0 -722
- package/build/esm/servers/server.builder.js.map +0 -1
- package/build/esm/servers/server.d.ts +0 -256
- package/build/esm/servers/server.js +0 -1211
- package/build/esm/servers/server.js.map +0 -1
- package/build/esm/types/api-response.d.ts +0 -124
- package/build/esm/types/api-response.js +0 -25
- package/build/esm/types/api-response.js.map +0 -1
- package/build/esm/types/index.d.ts +0 -125
- package/build/esm/types/index.js +0 -25
- package/build/esm/types/index.js.map +0 -1
- package/build/esm/types/server.d.ts +0 -285
- package/build/esm/types/server.js +0 -25
- package/build/esm/types/server.js.map +0 -1
- package/build/esm/utils/array.utils.d.ts +0 -168
- package/build/esm/utils/array.utils.js +0 -382
- package/build/esm/utils/array.utils.js.map +0 -1
- package/build/esm/utils/async.utils.d.ts +0 -174
- package/build/esm/utils/async.utils.js +0 -652
- package/build/esm/utils/async.utils.js.map +0 -1
- package/build/esm/utils/cache.utils.d.ts +0 -153
- package/build/esm/utils/cache.utils.js +0 -499
- package/build/esm/utils/cache.utils.js.map +0 -1
- package/build/esm/utils/context-store.utils.d.ts +0 -186
- package/build/esm/utils/context-store.utils.js +0 -304
- package/build/esm/utils/context-store.utils.js.map +0 -1
- package/build/esm/utils/crypto.utils.d.ts +0 -160
- package/build/esm/utils/crypto.utils.js +0 -375
- package/build/esm/utils/crypto.utils.js.map +0 -1
- package/build/esm/utils/decorators.utils.d.ts +0 -315
- package/build/esm/utils/decorators.utils.js +0 -666
- package/build/esm/utils/decorators.utils.js.map +0 -1
- package/build/esm/utils/dir.utils.d.ts +0 -196
- package/build/esm/utils/dir.utils.js +0 -998
- package/build/esm/utils/dir.utils.js.map +0 -1
- package/build/esm/utils/env.utils.d.ts +0 -377
- package/build/esm/utils/env.utils.js +0 -873
- package/build/esm/utils/env.utils.js.map +0 -1
- package/build/esm/utils/exception.utils.d.ts +0 -230
- package/build/esm/utils/exception.utils.js +0 -559
- package/build/esm/utils/exception.utils.js.map +0 -1
- package/build/esm/utils/fs.utils.d.ts +0 -164
- package/build/esm/utils/fs.utils.js +0 -580
- package/build/esm/utils/fs.utils.js.map +0 -1
- package/build/esm/utils/http-status-codes.d.ts +0 -266
- package/build/esm/utils/http-status-codes.js +0 -295
- package/build/esm/utils/http-status-codes.js.map +0 -1
- package/build/esm/utils/id.utils.d.ts +0 -36
- package/build/esm/utils/id.utils.js +0 -87
- package/build/esm/utils/id.utils.js.map +0 -1
- package/build/esm/utils/logger.utils.d.ts +0 -166
- package/build/esm/utils/logger.utils.js +0 -347
- package/build/esm/utils/logger.utils.js.map +0 -1
- package/build/esm/utils/middleware.utils.d.ts +0 -83
- package/build/esm/utils/middleware.utils.js +0 -205
- package/build/esm/utils/middleware.utils.js.map +0 -1
- package/build/esm/utils/obj.utils.d.ts +0 -124
- package/build/esm/utils/obj.utils.js +0 -519
- package/build/esm/utils/obj.utils.js.map +0 -1
- package/build/esm/utils/request.utils.d.ts +0 -77
- package/build/esm/utils/request.utils.js +0 -196
- package/build/esm/utils/request.utils.js.map +0 -1
- package/build/esm/utils/response.utils.d.ts +0 -163
- package/build/esm/utils/response.utils.js +0 -284
- package/build/esm/utils/response.utils.js.map +0 -1
- package/build/esm/utils/string.utils.d.ts +0 -93
- package/build/esm/utils/string.utils.js +0 -169
- package/build/esm/utils/string.utils.js.map +0 -1
- package/build/esm/utils/url.utils.d.ts +0 -141
- package/build/esm/utils/url.utils.js +0 -381
- package/build/esm/utils/url.utils.js.map +0 -1
- package/build/esm/utils/validate.utils.d.ts +0 -177
- package/build/esm/utils/validate.utils.js +0 -336
- package/build/esm/utils/validate.utils.js.map +0 -1
- package/build/esnext/config.d.ts +0 -130
- package/build/esnext/config.js +0 -145
- package/build/esnext/config.js.map +0 -1
- package/build/esnext/index.d.ts +0 -27
- package/build/esnext/index.js +0 -50
- package/build/esnext/index.js.map +0 -1
- package/build/esnext/servers/server.builder.d.ts +0 -625
- package/build/esnext/servers/server.builder.js +0 -677
- package/build/esnext/servers/server.builder.js.map +0 -1
- package/build/esnext/servers/server.d.ts +0 -256
- package/build/esnext/servers/server.js +0 -918
- package/build/esnext/servers/server.js.map +0 -1
- package/build/esnext/types/api-response.d.ts +0 -124
- package/build/esnext/types/api-response.js +0 -25
- package/build/esnext/types/api-response.js.map +0 -1
- package/build/esnext/types/index.d.ts +0 -125
- package/build/esnext/types/index.js +0 -25
- package/build/esnext/types/index.js.map +0 -1
- package/build/esnext/types/server.d.ts +0 -285
- package/build/esnext/types/server.js +0 -25
- package/build/esnext/types/server.js.map +0 -1
- package/build/esnext/utils/array.utils.d.ts +0 -168
- package/build/esnext/utils/array.utils.js +0 -345
- package/build/esnext/utils/array.utils.js.map +0 -1
- package/build/esnext/utils/async.utils.d.ts +0 -174
- package/build/esnext/utils/async.utils.js +0 -430
- package/build/esnext/utils/async.utils.js.map +0 -1
- package/build/esnext/utils/cache.utils.d.ts +0 -153
- package/build/esnext/utils/cache.utils.js +0 -293
- package/build/esnext/utils/cache.utils.js.map +0 -1
- package/build/esnext/utils/context-store.utils.d.ts +0 -186
- package/build/esnext/utils/context-store.utils.js +0 -286
- package/build/esnext/utils/context-store.utils.js.map +0 -1
- package/build/esnext/utils/crypto.utils.d.ts +0 -160
- package/build/esnext/utils/crypto.utils.js +0 -276
- package/build/esnext/utils/crypto.utils.js.map +0 -1
- package/build/esnext/utils/decorators.utils.d.ts +0 -315
- package/build/esnext/utils/decorators.utils.js +0 -504
- package/build/esnext/utils/decorators.utils.js.map +0 -1
- package/build/esnext/utils/dir.utils.d.ts +0 -196
- package/build/esnext/utils/dir.utils.js +0 -477
- package/build/esnext/utils/dir.utils.js.map +0 -1
- package/build/esnext/utils/env.utils.d.ts +0 -377
- package/build/esnext/utils/env.utils.js +0 -785
- package/build/esnext/utils/env.utils.js.map +0 -1
- package/build/esnext/utils/exception.utils.d.ts +0 -230
- package/build/esnext/utils/exception.utils.js +0 -381
- package/build/esnext/utils/exception.utils.js.map +0 -1
- package/build/esnext/utils/fs.utils.d.ts +0 -164
- package/build/esnext/utils/fs.utils.js +0 -349
- package/build/esnext/utils/fs.utils.js.map +0 -1
- package/build/esnext/utils/http-status-codes.d.ts +0 -266
- package/build/esnext/utils/http-status-codes.js +0 -295
- package/build/esnext/utils/http-status-codes.js.map +0 -1
- package/build/esnext/utils/id.utils.d.ts +0 -36
- package/build/esnext/utils/id.utils.js +0 -84
- package/build/esnext/utils/id.utils.js.map +0 -1
- package/build/esnext/utils/logger.utils.d.ts +0 -166
- package/build/esnext/utils/logger.utils.js +0 -306
- package/build/esnext/utils/logger.utils.js.map +0 -1
- package/build/esnext/utils/middleware.utils.d.ts +0 -83
- package/build/esnext/utils/middleware.utils.js +0 -198
- package/build/esnext/utils/middleware.utils.js.map +0 -1
- package/build/esnext/utils/obj.utils.d.ts +0 -124
- package/build/esnext/utils/obj.utils.js +0 -413
- package/build/esnext/utils/obj.utils.js.map +0 -1
- package/build/esnext/utils/request.utils.d.ts +0 -77
- package/build/esnext/utils/request.utils.js +0 -168
- package/build/esnext/utils/request.utils.js.map +0 -1
- package/build/esnext/utils/response.utils.d.ts +0 -163
- package/build/esnext/utils/response.utils.js +0 -247
- package/build/esnext/utils/response.utils.js.map +0 -1
- package/build/esnext/utils/string.utils.d.ts +0 -93
- package/build/esnext/utils/string.utils.js +0 -165
- package/build/esnext/utils/string.utils.js.map +0 -1
- package/build/esnext/utils/url.utils.d.ts +0 -141
- package/build/esnext/utils/url.utils.js +0 -304
- package/build/esnext/utils/url.utils.js.map +0 -1
- package/build/esnext/utils/validate.utils.d.ts +0 -177
- package/build/esnext/utils/validate.utils.js +0 -320
- package/build/esnext/utils/validate.utils.js.map +0 -1
- package/build/src/config.d.ts +0 -130
- package/build/src/config.js +0 -150
- package/build/src/config.js.map +0 -1
- package/build/src/index.d.ts +0 -27
- package/build/src/index.js +0 -69
- package/build/src/index.js.map +0 -1
- package/build/src/servers/server.builder.d.ts +0 -625
- package/build/src/servers/server.builder.js +0 -681
- package/build/src/servers/server.builder.js.map +0 -1
- package/build/src/servers/server.d.ts +0 -256
- package/build/src/servers/server.js +0 -958
- package/build/src/servers/server.js.map +0 -1
- package/build/src/types/api-response.d.ts +0 -124
- package/build/src/types/api-response.js +0 -26
- package/build/src/types/api-response.js.map +0 -1
- package/build/src/types/index.d.ts +0 -125
- package/build/src/types/index.js +0 -26
- package/build/src/types/index.js.map +0 -1
- package/build/src/types/server.d.ts +0 -285
- package/build/src/types/server.js +0 -26
- package/build/src/types/server.js.map +0 -1
- package/build/src/utils/array.utils.d.ts +0 -168
- package/build/src/utils/array.utils.js +0 -364
- package/build/src/utils/array.utils.js.map +0 -1
- package/build/src/utils/async.utils.d.ts +0 -174
- package/build/src/utils/async.utils.js +0 -447
- package/build/src/utils/async.utils.js.map +0 -1
- package/build/src/utils/cache.utils.d.ts +0 -153
- package/build/src/utils/cache.utils.js +0 -297
- package/build/src/utils/cache.utils.js.map +0 -1
- package/build/src/utils/context-store.utils.d.ts +0 -186
- package/build/src/utils/context-store.utils.js +0 -293
- package/build/src/utils/context-store.utils.js.map +0 -1
- package/build/src/utils/crypto.utils.d.ts +0 -160
- package/build/src/utils/crypto.utils.js +0 -293
- package/build/src/utils/crypto.utils.js.map +0 -1
- package/build/src/utils/decorators.utils.d.ts +0 -315
- package/build/src/utils/decorators.utils.js +0 -516
- package/build/src/utils/decorators.utils.js.map +0 -1
- package/build/src/utils/dir.utils.d.ts +0 -196
- package/build/src/utils/dir.utils.js +0 -501
- package/build/src/utils/dir.utils.js.map +0 -1
- package/build/src/utils/env.utils.d.ts +0 -377
- package/build/src/utils/env.utils.js +0 -789
- package/build/src/utils/env.utils.js.map +0 -1
- package/build/src/utils/exception.utils.d.ts +0 -230
- package/build/src/utils/exception.utils.js +0 -407
- package/build/src/utils/exception.utils.js.map +0 -1
- package/build/src/utils/fs.utils.d.ts +0 -164
- package/build/src/utils/fs.utils.js +0 -372
- package/build/src/utils/fs.utils.js.map +0 -1
- package/build/src/utils/http-status-codes.d.ts +0 -266
- package/build/src/utils/http-status-codes.js +0 -298
- package/build/src/utils/http-status-codes.js.map +0 -1
- package/build/src/utils/id.utils.d.ts +0 -36
- package/build/src/utils/id.utils.js +0 -91
- package/build/src/utils/id.utils.js.map +0 -1
- package/build/src/utils/logger.utils.d.ts +0 -166
- package/build/src/utils/logger.utils.js +0 -352
- package/build/src/utils/logger.utils.js.map +0 -1
- package/build/src/utils/middleware.utils.d.ts +0 -83
- package/build/src/utils/middleware.utils.js +0 -205
- package/build/src/utils/middleware.utils.js.map +0 -1
- package/build/src/utils/obj.utils.d.ts +0 -124
- package/build/src/utils/obj.utils.js +0 -429
- package/build/src/utils/obj.utils.js.map +0 -1
- package/build/src/utils/request.utils.d.ts +0 -77
- package/build/src/utils/request.utils.js +0 -175
- package/build/src/utils/request.utils.js.map +0 -1
- package/build/src/utils/response.utils.d.ts +0 -163
- package/build/src/utils/response.utils.js +0 -260
- package/build/src/utils/response.utils.js.map +0 -1
- package/build/src/utils/string.utils.d.ts +0 -93
- package/build/src/utils/string.utils.js +0 -179
- package/build/src/utils/string.utils.js.map +0 -1
- package/build/src/utils/url.utils.d.ts +0 -141
- package/build/src/utils/url.utils.js +0 -317
- package/build/src/utils/url.utils.js.map +0 -1
- package/build/src/utils/validate.utils.d.ts +0 -177
- package/build/src/utils/validate.utils.js +0 -345
- package/build/src/utils/validate.utils.js.map +0 -1
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks whether the object has no own enumerable properties.
|
|
3
|
-
*
|
|
4
|
-
* @param {Record<any, any>} obj - The object to check.
|
|
5
|
-
* @returns {boolean} True if the object is empty, false otherwise.
|
|
6
|
-
*/
|
|
7
|
-
export declare function isObjEmpty(obj: Record<any, any>): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Returns a new object with only the specified keys picked.
|
|
10
|
-
*
|
|
11
|
-
* @template T
|
|
12
|
-
* @template K
|
|
13
|
-
* @param {T} obj - The source object.
|
|
14
|
-
* @param {K[]} keys - Keys to pick from the object.
|
|
15
|
-
* @returns {Pick<T, K>} New object with picked keys.
|
|
16
|
-
*/
|
|
17
|
-
export declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
18
|
-
/**
|
|
19
|
-
* Returns a new object with the specified keys omitted.
|
|
20
|
-
*
|
|
21
|
-
* @template T
|
|
22
|
-
* @template K
|
|
23
|
-
* @param {T} obj - The source object.
|
|
24
|
-
* @param {K[]} keys - Keys to omit from the object.
|
|
25
|
-
* @returns {Omit<T, K>} New object without omitted keys.
|
|
26
|
-
*/
|
|
27
|
-
export declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
28
|
-
/**
|
|
29
|
-
* Deeply merges multiple objects into the target object (mutates and returns the target object, not pure).
|
|
30
|
-
*
|
|
31
|
-
* @template T
|
|
32
|
-
* @param {T} target - The object to merge into (will be mutated).
|
|
33
|
-
* @param {...any[]} sources - The objects to merge from.
|
|
34
|
-
* @returns {T} The merged object (same as target).
|
|
35
|
-
*/
|
|
36
|
-
export declare function deepObjMerge<T extends object>(target: T, ...sources: any[]): T;
|
|
37
|
-
/**
|
|
38
|
-
* Checks if a value is a plain object (i.e., not an array, null, or a built-in object).
|
|
39
|
-
*
|
|
40
|
-
* @param value - The value to check.
|
|
41
|
-
* @returns True if the value is a plain object, false otherwise.
|
|
42
|
-
*/
|
|
43
|
-
export declare function isPlainObject(value: any): value is Record<string, any>;
|
|
44
|
-
/**
|
|
45
|
-
* Flattens a nested object using dot notation for keys (e.g., `{a: {b: 1}}` → `{ "a.b": 1 }`).
|
|
46
|
-
*
|
|
47
|
-
* @template T
|
|
48
|
-
* @param {T} obj - The object to flatten.
|
|
49
|
-
* @param {string} [prefix=""] - Optional prefix for nested keys (used internally).
|
|
50
|
-
* @returns {Record<string, any>} A new object with flattened keys.
|
|
51
|
-
*/
|
|
52
|
-
export declare function flattenObject<T extends Record<string, any>>(obj: T, prefix?: string): Record<string, any>;
|
|
53
|
-
/**
|
|
54
|
-
* Safely gets the value of a deeply nested key in an object using dot/bracket notation path.
|
|
55
|
-
*
|
|
56
|
-
* @template T
|
|
57
|
-
* @param {T} obj - The object to extract from.
|
|
58
|
-
* @param {string} path - String path using dot and/or bracket notation (e.g., 'user.friends[0].name').
|
|
59
|
-
* @returns {any} The value at the given path, or undefined if not found.
|
|
60
|
-
*/
|
|
61
|
-
export declare function getValueByPath<T extends object>(obj: T, path: string): any;
|
|
62
|
-
/**
|
|
63
|
-
* Sets a value at a deeply nested key in an object using dot/bracket notation path.
|
|
64
|
-
* Creates intermediate objects and arrays as needed.
|
|
65
|
-
*
|
|
66
|
-
* @template T
|
|
67
|
-
* @param {T} obj - The object to modify.
|
|
68
|
-
* @param {string} path - String path using dot and/or bracket notation (e.g., 'user.friends[0].name').
|
|
69
|
-
* @param {any} value - The value to set at the path.
|
|
70
|
-
* @returns {T} The modified object.
|
|
71
|
-
*/
|
|
72
|
-
export declare function setValueByPath<T extends object>(obj: T, path: string, value: any): T;
|
|
73
|
-
/**
|
|
74
|
-
* Performs a deep equality check between two objects.
|
|
75
|
-
*
|
|
76
|
-
* @param {any} a - First value to compare.
|
|
77
|
-
* @param {any} b - Second value to compare.
|
|
78
|
-
* @returns {boolean} True if values are deeply equal.
|
|
79
|
-
*/
|
|
80
|
-
export declare function isEqual(a: any, b: any): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Filters object properties based on a predicate function.
|
|
83
|
-
*
|
|
84
|
-
* @template T
|
|
85
|
-
* @param {T} obj - The source object.
|
|
86
|
-
* @param {(value: any, key: string, obj: T) => boolean} predicate - Filter function.
|
|
87
|
-
* @returns {Partial<T>} New object with filtered properties.
|
|
88
|
-
*/
|
|
89
|
-
export declare function filterObject<T extends object>(obj: T, predicate: (value: any, key: string, obj: T) => boolean): Partial<T>;
|
|
90
|
-
/**
|
|
91
|
-
* Maps object values to new values using a mapping function.
|
|
92
|
-
*
|
|
93
|
-
* @template T
|
|
94
|
-
* @template U
|
|
95
|
-
* @param {T} obj - The source object.
|
|
96
|
-
* @param {(value: any, key: string, obj: T) => U} mapFn - Mapping function.
|
|
97
|
-
* @returns {Record<keyof T, U>} New object with mapped values.
|
|
98
|
-
*/
|
|
99
|
-
export declare function mapObject<T extends object, U>(obj: T, mapFn: (value: any, key: string, obj: T) => U): Record<keyof T, U>;
|
|
100
|
-
/**
|
|
101
|
-
* Recursively freezes an object and all its properties.
|
|
102
|
-
* Makes an object immutable.
|
|
103
|
-
*
|
|
104
|
-
* @template T
|
|
105
|
-
* @param {T} obj - The object to freeze.
|
|
106
|
-
* @returns {Readonly<T>} The frozen object.
|
|
107
|
-
*/
|
|
108
|
-
export declare function deepFreeze<T extends object>(obj: T): Readonly<T>;
|
|
109
|
-
/**
|
|
110
|
-
* Safely checks if a value is an object (not null, not array).
|
|
111
|
-
*
|
|
112
|
-
* @param {unknown} value - Value to check.
|
|
113
|
-
* @returns {boolean} True if value is a non-null, non-array object.
|
|
114
|
-
*/
|
|
115
|
-
export declare function isObject(value: unknown): value is Record<string, any>;
|
|
116
|
-
/**
|
|
117
|
-
* Gets all paths in an object using dot notation.
|
|
118
|
-
*
|
|
119
|
-
* @param {Record<string, any>} obj - Object to analyze.
|
|
120
|
-
* @param {string} [parentPath=""] - Internal param for recursion.
|
|
121
|
-
* @returns {string[]} Array of all paths in dot notation.
|
|
122
|
-
*/
|
|
123
|
-
export declare function getAllPaths(obj: Record<string, any>, parentPath?: string): string[];
|
|
124
|
-
//# sourceMappingURL=obj.utils.d.ts.map
|
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2025 Catbee Technologies
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* Checks whether the object has no own enumerable properties.
|
|
26
|
-
*
|
|
27
|
-
* @param {Record<any, any>} obj - The object to check.
|
|
28
|
-
* @returns {boolean} True if the object is empty, false otherwise.
|
|
29
|
-
*/
|
|
30
|
-
export function isObjEmpty(obj) {
|
|
31
|
-
return !!obj && typeof obj === 'object' && Object.keys(obj).length === 0;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns a new object with only the specified keys picked.
|
|
35
|
-
*
|
|
36
|
-
* @template T
|
|
37
|
-
* @template K
|
|
38
|
-
* @param {T} obj - The source object.
|
|
39
|
-
* @param {K[]} keys - Keys to pick from the object.
|
|
40
|
-
* @returns {Pick<T, K>} New object with picked keys.
|
|
41
|
-
*/
|
|
42
|
-
export function pick(obj, keys) {
|
|
43
|
-
return Object.fromEntries(keys.map(key => [key, obj[key]]));
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Returns a new object with the specified keys omitted.
|
|
47
|
-
*
|
|
48
|
-
* @template T
|
|
49
|
-
* @template K
|
|
50
|
-
* @param {T} obj - The source object.
|
|
51
|
-
* @param {K[]} keys - Keys to omit from the object.
|
|
52
|
-
* @returns {Omit<T, K>} New object without omitted keys.
|
|
53
|
-
*/
|
|
54
|
-
export function omit(obj, keys) {
|
|
55
|
-
return Object.fromEntries(Object.entries(obj).filter(([key]) => !keys.includes(key)));
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Deeply merges multiple objects into the target object (mutates and returns the target object, not pure).
|
|
59
|
-
*
|
|
60
|
-
* @template T
|
|
61
|
-
* @param {T} target - The object to merge into (will be mutated).
|
|
62
|
-
* @param {...any[]} sources - The objects to merge from.
|
|
63
|
-
* @returns {T} The merged object (same as target).
|
|
64
|
-
*/
|
|
65
|
-
export function deepObjMerge(target, ...sources) {
|
|
66
|
-
if (!sources.length)
|
|
67
|
-
return target;
|
|
68
|
-
const seen = new WeakMap();
|
|
69
|
-
seen.set(target, target);
|
|
70
|
-
for (const s of sources) {
|
|
71
|
-
if (s && typeof s === 'object') {
|
|
72
|
-
seen.set(s, target);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function deepClone(value) {
|
|
76
|
-
if (value === null || typeof value !== 'object')
|
|
77
|
-
return value;
|
|
78
|
-
if (seen.has(value))
|
|
79
|
-
return seen.get(value);
|
|
80
|
-
// Date
|
|
81
|
-
if (value instanceof Date) {
|
|
82
|
-
return new Date(value.getTime());
|
|
83
|
-
}
|
|
84
|
-
// Array
|
|
85
|
-
if (Array.isArray(value)) {
|
|
86
|
-
const clone = [];
|
|
87
|
-
seen.set(value, clone);
|
|
88
|
-
value.forEach((item, i) => (clone[i] = deepClone(item)));
|
|
89
|
-
return clone;
|
|
90
|
-
}
|
|
91
|
-
// Set
|
|
92
|
-
if (value instanceof Set) {
|
|
93
|
-
const clone = new Set();
|
|
94
|
-
seen.set(value, clone);
|
|
95
|
-
value.forEach(item => clone.add(deepClone(item)));
|
|
96
|
-
return clone;
|
|
97
|
-
}
|
|
98
|
-
// Map
|
|
99
|
-
if (value instanceof Map) {
|
|
100
|
-
const clone = new Map();
|
|
101
|
-
seen.set(value, clone);
|
|
102
|
-
value.forEach((val, key) => clone.set(key, deepClone(val)));
|
|
103
|
-
return clone;
|
|
104
|
-
}
|
|
105
|
-
// RegExp
|
|
106
|
-
if (value instanceof RegExp) {
|
|
107
|
-
return new RegExp(value.source, value.flags);
|
|
108
|
-
}
|
|
109
|
-
// ArrayBuffer
|
|
110
|
-
if (value instanceof ArrayBuffer) {
|
|
111
|
-
return value.slice(0);
|
|
112
|
-
}
|
|
113
|
-
// TypedArrays
|
|
114
|
-
if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
|
|
115
|
-
const typed = value; // cast for TS
|
|
116
|
-
const ctor = typed.constructor;
|
|
117
|
-
// List of standard TypedArray constructors
|
|
118
|
-
const typedArrayCtors = [
|
|
119
|
-
Int8Array,
|
|
120
|
-
Uint8Array,
|
|
121
|
-
Uint8ClampedArray,
|
|
122
|
-
Int16Array,
|
|
123
|
-
Uint16Array,
|
|
124
|
-
Int32Array,
|
|
125
|
-
Uint32Array,
|
|
126
|
-
Float32Array,
|
|
127
|
-
Float64Array,
|
|
128
|
-
BigInt64Array,
|
|
129
|
-
BigUint64Array
|
|
130
|
-
].filter(Boolean); // filter out undefined (for environments without BigInt)
|
|
131
|
-
const typedArrayCtorSet = new Set(typedArrayCtors);
|
|
132
|
-
if (typeof ctor === 'function' && typedArrayCtorSet.has(ctor)) {
|
|
133
|
-
// Defensive: ensure buffer is an ArrayBuffer and slice is available
|
|
134
|
-
const buffer = typed.buffer && typeof typed.buffer.slice === 'function' ? typed.buffer.slice(0) : typed.buffer;
|
|
135
|
-
const clone = new ctor(buffer, typed.byteOffset, typed.length);
|
|
136
|
-
seen.set(value, clone);
|
|
137
|
-
return clone;
|
|
138
|
-
}
|
|
139
|
-
else if (typeof typed.slice === 'function') {
|
|
140
|
-
// Fallback: try using slice if available (e.g., Node.js Buffer)
|
|
141
|
-
const clone = typed.slice();
|
|
142
|
-
seen.set(value, clone);
|
|
143
|
-
return clone;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
// Could not safely clone, throw an error for better debugging
|
|
147
|
-
throw new Error('Cannot deep clone unknown TypedArray type: ' + (typed && typed.constructor && typed.constructor.name));
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
const clone = Object.create(Object.getPrototypeOf(value));
|
|
151
|
-
seen.set(value, clone);
|
|
152
|
-
Reflect.ownKeys(value).forEach(key => {
|
|
153
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
154
|
-
if (descriptor.get || descriptor.set) {
|
|
155
|
-
Object.defineProperty(clone, key, descriptor);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
clone[key] = deepClone(value[key]);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
return clone;
|
|
162
|
-
}
|
|
163
|
-
function mergeProp(target, source, key) {
|
|
164
|
-
const targetValue = target[key];
|
|
165
|
-
const sourceValue = source[key];
|
|
166
|
-
// Ignore undefined in source
|
|
167
|
-
if (sourceValue === undefined)
|
|
168
|
-
return;
|
|
169
|
-
// Primitives → overwrite directly
|
|
170
|
-
if (sourceValue === null || typeof sourceValue !== 'object') {
|
|
171
|
-
target[key] = sourceValue;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
// Arrays → replace (lodash behavior)
|
|
175
|
-
if (Array.isArray(sourceValue)) {
|
|
176
|
-
target[key] = deepClone(sourceValue);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
// Special cloneable objects
|
|
180
|
-
if (sourceValue instanceof Date ||
|
|
181
|
-
sourceValue instanceof RegExp ||
|
|
182
|
-
sourceValue instanceof Set ||
|
|
183
|
-
sourceValue instanceof Map ||
|
|
184
|
-
sourceValue instanceof ArrayBuffer ||
|
|
185
|
-
(ArrayBuffer.isView(sourceValue) && !(sourceValue instanceof DataView))) {
|
|
186
|
-
target[key] = deepClone(sourceValue);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
// Plain objects → recursive merge
|
|
190
|
-
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
191
|
-
for (const k of Reflect.ownKeys(sourceValue)) {
|
|
192
|
-
mergeProp(targetValue, sourceValue, k);
|
|
193
|
-
}
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
// Default → overwrite with clone
|
|
197
|
-
target[key] = deepClone(sourceValue);
|
|
198
|
-
}
|
|
199
|
-
for (const source of sources) {
|
|
200
|
-
if (source == null)
|
|
201
|
-
continue;
|
|
202
|
-
for (const key of Reflect.ownKeys(source)) {
|
|
203
|
-
mergeProp(target, source, key);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return target;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Checks if a value is a plain object (i.e., not an array, null, or a built-in object).
|
|
210
|
-
*
|
|
211
|
-
* @param value - The value to check.
|
|
212
|
-
* @returns True if the value is a plain object, false otherwise.
|
|
213
|
-
*/
|
|
214
|
-
export function isPlainObject(value) {
|
|
215
|
-
if (typeof value !== 'object' || value === null)
|
|
216
|
-
return false;
|
|
217
|
-
if (Array.isArray(value))
|
|
218
|
-
return false;
|
|
219
|
-
const proto = Object.getPrototypeOf(value);
|
|
220
|
-
return proto === Object.prototype || proto === null;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Flattens a nested object using dot notation for keys (e.g., `{a: {b: 1}}` → `{ "a.b": 1 }`).
|
|
224
|
-
*
|
|
225
|
-
* @template T
|
|
226
|
-
* @param {T} obj - The object to flatten.
|
|
227
|
-
* @param {string} [prefix=""] - Optional prefix for nested keys (used internally).
|
|
228
|
-
* @returns {Record<string, any>} A new object with flattened keys.
|
|
229
|
-
*/
|
|
230
|
-
export function flattenObject(obj, prefix = '') {
|
|
231
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
232
|
-
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
233
|
-
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
234
|
-
Object.assign(acc, flattenObject(value, newKey));
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
acc[newKey] = value;
|
|
238
|
-
}
|
|
239
|
-
return acc;
|
|
240
|
-
}, {});
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Safely gets the value of a deeply nested key in an object using dot/bracket notation path.
|
|
244
|
-
*
|
|
245
|
-
* @template T
|
|
246
|
-
* @param {T} obj - The object to extract from.
|
|
247
|
-
* @param {string} path - String path using dot and/or bracket notation (e.g., 'user.friends[0].name').
|
|
248
|
-
* @returns {any} The value at the given path, or undefined if not found.
|
|
249
|
-
*/
|
|
250
|
-
export function getValueByPath(obj, path) {
|
|
251
|
-
if (!obj || typeof obj !== 'object')
|
|
252
|
-
return undefined;
|
|
253
|
-
// Convert path like "a.b[0].c" into ["a", "b", "0", "c"]
|
|
254
|
-
const parts = path
|
|
255
|
-
.replace(/\[(\d+)\]/g, '.$1') // convert [0] to .0
|
|
256
|
-
.split('.')
|
|
257
|
-
.filter(Boolean); // remove empty strings
|
|
258
|
-
return parts.reduce((acc, key) => acc === null || acc === void 0 ? void 0 : acc[key], obj);
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Sets a value at a deeply nested key in an object using dot/bracket notation path.
|
|
262
|
-
* Creates intermediate objects and arrays as needed.
|
|
263
|
-
*
|
|
264
|
-
* @template T
|
|
265
|
-
* @param {T} obj - The object to modify.
|
|
266
|
-
* @param {string} path - String path using dot and/or bracket notation (e.g., 'user.friends[0].name').
|
|
267
|
-
* @param {any} value - The value to set at the path.
|
|
268
|
-
* @returns {T} The modified object.
|
|
269
|
-
*/
|
|
270
|
-
export function setValueByPath(obj, path, value) {
|
|
271
|
-
if (!obj || typeof obj !== 'object')
|
|
272
|
-
return obj;
|
|
273
|
-
// Convert path like "a.b[0].c" into ["a", "b", "0", "c"]
|
|
274
|
-
const parts = path
|
|
275
|
-
.replace(/\[(\d+)\]/g, '.$1') // convert [0] to .0
|
|
276
|
-
.split('.')
|
|
277
|
-
.filter(Boolean); // remove empty strings
|
|
278
|
-
// Handle empty path
|
|
279
|
-
if (parts.length === 0)
|
|
280
|
-
return obj;
|
|
281
|
-
let current = obj;
|
|
282
|
-
// Navigate to the parent of the target property
|
|
283
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
284
|
-
const key = parts[i];
|
|
285
|
-
const isArrayIndex = !isNaN(Number(parts[i + 1]));
|
|
286
|
-
if (current[key] === undefined) {
|
|
287
|
-
// Create intermediate object or array based on next key type
|
|
288
|
-
current[key] = isArrayIndex ? [] : {};
|
|
289
|
-
}
|
|
290
|
-
current = current[key];
|
|
291
|
-
}
|
|
292
|
-
// Set the value at the final key
|
|
293
|
-
const finalKey = parts[parts.length - 1];
|
|
294
|
-
current[finalKey] = value;
|
|
295
|
-
return obj;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Performs a deep equality check between two objects.
|
|
299
|
-
*
|
|
300
|
-
* @param {any} a - First value to compare.
|
|
301
|
-
* @param {any} b - Second value to compare.
|
|
302
|
-
* @returns {boolean} True if values are deeply equal.
|
|
303
|
-
*/
|
|
304
|
-
export function isEqual(a, b) {
|
|
305
|
-
// Check if primitives or references to the same object
|
|
306
|
-
if (a === b)
|
|
307
|
-
return true;
|
|
308
|
-
// Check if either is null/undefined or not an object
|
|
309
|
-
if (a == null || b == null || typeof a !== 'object' || typeof b !== 'object') {
|
|
310
|
-
return false;
|
|
311
|
-
}
|
|
312
|
-
// Handle Date objects
|
|
313
|
-
if (a instanceof Date && b instanceof Date) {
|
|
314
|
-
return a.getTime() === b.getTime();
|
|
315
|
-
}
|
|
316
|
-
// If one is Date but the other isn't
|
|
317
|
-
if (a instanceof Date || b instanceof Date) {
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
// Handle arrays
|
|
321
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
322
|
-
if (a.length !== b.length)
|
|
323
|
-
return false;
|
|
324
|
-
// Check each element
|
|
325
|
-
for (let i = 0; i < a.length; i++) {
|
|
326
|
-
if (!isEqual(a[i], b[i]))
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
return true;
|
|
330
|
-
}
|
|
331
|
-
// If one is Array but the other isn't
|
|
332
|
-
if (Array.isArray(a) || Array.isArray(b)) {
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
// Compare object keys
|
|
336
|
-
const keysA = Object.keys(a);
|
|
337
|
-
const keysB = Object.keys(b);
|
|
338
|
-
if (keysA.length !== keysB.length)
|
|
339
|
-
return false;
|
|
340
|
-
// Check if every key in A exists in B and has the same value
|
|
341
|
-
return keysA.every(key => Object.prototype.hasOwnProperty.call(b, key) && isEqual(a[key], b[key]));
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Filters object properties based on a predicate function.
|
|
345
|
-
*
|
|
346
|
-
* @template T
|
|
347
|
-
* @param {T} obj - The source object.
|
|
348
|
-
* @param {(value: any, key: string, obj: T) => boolean} predicate - Filter function.
|
|
349
|
-
* @returns {Partial<T>} New object with filtered properties.
|
|
350
|
-
*/
|
|
351
|
-
export function filterObject(obj, predicate) {
|
|
352
|
-
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => predicate(value, key, obj)));
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Maps object values to new values using a mapping function.
|
|
356
|
-
*
|
|
357
|
-
* @template T
|
|
358
|
-
* @template U
|
|
359
|
-
* @param {T} obj - The source object.
|
|
360
|
-
* @param {(value: any, key: string, obj: T) => U} mapFn - Mapping function.
|
|
361
|
-
* @returns {Record<keyof T, U>} New object with mapped values.
|
|
362
|
-
*/
|
|
363
|
-
export function mapObject(obj, mapFn) {
|
|
364
|
-
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, mapFn(value, key, obj)]));
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Recursively freezes an object and all its properties.
|
|
368
|
-
* Makes an object immutable.
|
|
369
|
-
*
|
|
370
|
-
* @template T
|
|
371
|
-
* @param {T} obj - The object to freeze.
|
|
372
|
-
* @returns {Readonly<T>} The frozen object.
|
|
373
|
-
*/
|
|
374
|
-
export function deepFreeze(obj) {
|
|
375
|
-
// Freeze primitive properties
|
|
376
|
-
Object.freeze(obj);
|
|
377
|
-
// Recursively freeze nested objects
|
|
378
|
-
for (const prop of Object.getOwnPropertyNames(obj)) {
|
|
379
|
-
const value = obj[prop];
|
|
380
|
-
if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
381
|
-
deepFreeze(value);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
return obj;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Safely checks if a value is an object (not null, not array).
|
|
388
|
-
*
|
|
389
|
-
* @param {unknown} value - Value to check.
|
|
390
|
-
* @returns {boolean} True if value is a non-null, non-array object.
|
|
391
|
-
*/
|
|
392
|
-
export function isObject(value) {
|
|
393
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Gets all paths in an object using dot notation.
|
|
397
|
-
*
|
|
398
|
-
* @param {Record<string, any>} obj - Object to analyze.
|
|
399
|
-
* @param {string} [parentPath=""] - Internal param for recursion.
|
|
400
|
-
* @returns {string[]} Array of all paths in dot notation.
|
|
401
|
-
*/
|
|
402
|
-
export function getAllPaths(obj, parentPath = '') {
|
|
403
|
-
if (!isObject(obj))
|
|
404
|
-
return [];
|
|
405
|
-
return Object.entries(obj).flatMap(([key, value]) => {
|
|
406
|
-
const currentPath = parentPath ? `${parentPath}.${key}` : key;
|
|
407
|
-
if (isObject(value)) {
|
|
408
|
-
return [currentPath, ...getAllPaths(value, currentPath)];
|
|
409
|
-
}
|
|
410
|
-
return [currentPath];
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
//# sourceMappingURL=obj.utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"obj.utils.js","sourceRoot":"","sources":["../../../src/utils/obj.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAqB;IAC9C,OAAO,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAAsC,GAAM,EAAE,IAAS;IACzE,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAe,CAAC;AAC5E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAAsC,GAAM,EAAE,IAAS;IACzE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ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AC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3E,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,GAAwB,EAAE,aAAqB,EAAE;IAC3E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAE9B,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAClD,MAAM,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAE9D,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,CAAC,WAAW,EAAE,GAAG,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,CAAC,WAAW,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * The MIT License\n *\n * Copyright (c) 2025 Catbee Technologies\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Checks whether the object has no own enumerable properties.\n *\n * @param {Record<any, any>} obj - The object to check.\n * @returns {boolean} True if the object is empty, false otherwise.\n */\nexport function isObjEmpty(obj: Record<any, any>): boolean {\n return !!obj && typeof obj === 'object' && Object.keys(obj).length === 0;\n}\n\n/**\n * Returns a new object with only the specified keys picked.\n *\n * @template T\n * @template K\n * @param {T} obj - The source object.\n * @param {K[]} keys - Keys to pick from the object.\n * @returns {Pick<T, K>} New object with picked keys.\n */\nexport function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n return Object.fromEntries(keys.map(key => [key, obj[key]])) as Pick<T, K>;\n}\n\n/**\n * Returns a new object with the specified keys omitted.\n *\n * @template T\n * @template K\n * @param {T} obj - The source object.\n * @param {K[]} keys - Keys to omit from the object.\n * @returns {Omit<T, K>} New object without omitted keys.\n */\nexport function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n return Object.fromEntries(Object.entries(obj).filter(([key]) => !keys.includes(key as K))) as Omit<T, K>;\n}\n\n/**\n * Deeply merges multiple objects into the target object (mutates and returns the target object, not pure).\n *\n * @template T\n * @param {T} target - The object to merge into (will be mutated).\n * @param {...any[]} sources - The objects to merge from.\n * @returns {T} The merged object (same as target).\n */\nexport function deepObjMerge<T extends object>(target: T, ...sources: any[]): T {\n if (!sources.length) return target;\n\n const seen = new WeakMap();\n seen.set(target, target);\n\n for (const s of sources) {\n if (s && typeof s === 'object') {\n seen.set(s, target);\n }\n }\n\n function deepClone(value: any): any {\n if (value === null || typeof value !== 'object') return value;\n\n if (seen.has(value)) return seen.get(value);\n\n // Date\n if (value instanceof Date) {\n return new Date(value.getTime());\n }\n\n // Array\n if (Array.isArray(value)) {\n const clone: any[] = [];\n seen.set(value, clone);\n value.forEach((item, i) => (clone[i] = deepClone(item)));\n return clone;\n }\n\n // Set\n if (value instanceof Set) {\n const clone = new Set();\n seen.set(value, clone);\n value.forEach(item => clone.add(deepClone(item)));\n return clone;\n }\n\n // Map\n if (value instanceof Map) {\n const clone = new Map();\n seen.set(value, clone);\n value.forEach((val, key) => clone.set(key, deepClone(val)));\n return clone;\n }\n\n // RegExp\n if (value instanceof RegExp) {\n return new RegExp(value.source, value.flags);\n }\n\n // ArrayBuffer\n if (value instanceof ArrayBuffer) {\n return value.slice(0);\n }\n\n // TypedArrays\n if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {\n const typed = value as any; // cast for TS\n const ctor = typed.constructor;\n // List of standard TypedArray constructors\n const typedArrayCtors = [\n Int8Array,\n Uint8Array,\n Uint8ClampedArray,\n Int16Array,\n Uint16Array,\n Int32Array,\n Uint32Array,\n Float32Array,\n Float64Array,\n BigInt64Array,\n BigUint64Array\n ].filter(Boolean); // filter out undefined (for environments without BigInt)\n const typedArrayCtorSet = new Set(typedArrayCtors);\n if (typeof ctor === 'function' && typedArrayCtorSet.has(ctor)) {\n // Defensive: ensure buffer is an ArrayBuffer and slice is available\n const buffer = typed.buffer && typeof typed.buffer.slice === 'function' ? typed.buffer.slice(0) : typed.buffer;\n const clone = new ctor(buffer, typed.byteOffset, typed.length);\n seen.set(value, clone);\n return clone;\n } else if (typeof typed.slice === 'function') {\n // Fallback: try using slice if available (e.g., Node.js Buffer)\n const clone = typed.slice();\n seen.set(value, clone);\n return clone;\n } else {\n // Could not safely clone, throw an error for better debugging\n throw new Error(\n 'Cannot deep clone unknown TypedArray type: ' + (typed && typed.constructor && typed.constructor.name)\n );\n }\n }\n\n const clone = Object.create(Object.getPrototypeOf(value));\n seen.set(value, clone);\n\n Reflect.ownKeys(value).forEach(key => {\n const descriptor = Object.getOwnPropertyDescriptor(value, key)!;\n if (descriptor.get || descriptor.set) {\n Object.defineProperty(clone, key, descriptor);\n } else {\n (clone as any)[key] = deepClone((value as any)[key]);\n }\n });\n\n return clone;\n }\n\n function mergeProp(target: any, source: any, key: string | symbol): void {\n const targetValue = target[key];\n const sourceValue = source[key];\n\n // Ignore undefined in source\n if (sourceValue === undefined) return;\n\n // Primitives → overwrite directly\n if (sourceValue === null || typeof sourceValue !== 'object') {\n target[key] = sourceValue;\n return;\n }\n\n // Arrays → replace (lodash behavior)\n if (Array.isArray(sourceValue)) {\n target[key] = deepClone(sourceValue);\n return;\n }\n\n // Special cloneable objects\n if (\n sourceValue instanceof Date ||\n sourceValue instanceof RegExp ||\n sourceValue instanceof Set ||\n sourceValue instanceof Map ||\n sourceValue instanceof ArrayBuffer ||\n (ArrayBuffer.isView(sourceValue) && !(sourceValue instanceof DataView))\n ) {\n target[key] = deepClone(sourceValue);\n return;\n }\n\n // Plain objects → recursive merge\n if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {\n for (const k of Reflect.ownKeys(sourceValue)) {\n mergeProp(targetValue, sourceValue, k);\n }\n return;\n }\n\n // Default → overwrite with clone\n target[key] = deepClone(sourceValue);\n }\n\n for (const source of sources) {\n if (source == null) continue;\n\n for (const key of Reflect.ownKeys(source)) {\n mergeProp(target, source, key);\n }\n }\n\n return target;\n}\n\n/**\n * Checks if a value is a plain object (i.e., not an array, null, or a built-in object).\n *\n * @param value - The value to check.\n * @returns True if the value is a plain object, false otherwise.\n */\nexport function isPlainObject(value: any): value is Record<string, any> {\n if (typeof value !== 'object' || value === null) return false;\n if (Array.isArray(value)) return false;\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/**\n * Flattens a nested object using dot notation for keys (e.g., `{a: {b: 1}}` → `{ \"a.b\": 1 }`).\n *\n * @template T\n * @param {T} obj - The object to flatten.\n * @param {string} [prefix=\"\"] - Optional prefix for nested keys (used internally).\n * @returns {Record<string, any>} A new object with flattened keys.\n */\nexport function flattenObject<T extends Record<string, any>>(obj: T, prefix = ''): Record<string, any> {\n return Object.entries(obj).reduce((acc: Record<string, any>, [key, value]) => {\n const newKey = prefix ? `${prefix}.${key}` : key;\n\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n Object.assign(acc, flattenObject(value, newKey));\n } else {\n acc[newKey] = value;\n }\n\n return acc;\n }, {});\n}\n\n/**\n * Safely gets the value of a deeply nested key in an object using dot/bracket notation path.\n *\n * @template T\n * @param {T} obj - The object to extract from.\n * @param {string} path - String path using dot and/or bracket notation (e.g., 'user.friends[0].name').\n * @returns {any} The value at the given path, or undefined if not found.\n */\nexport function getValueByPath<T extends object>(obj: T, path: string) {\n if (!obj || typeof obj !== 'object') return undefined;\n\n // Convert path like \"a.b[0].c\" into [\"a\", \"b\", \"0\", \"c\"]\n const parts = path\n .replace(/\\[(\\d+)\\]/g, '.$1') // convert [0] to .0\n .split('.')\n .filter(Boolean); // remove empty strings\n\n return parts.reduce((acc: any, key: string) => acc?.[key], obj);\n}\n\n/**\n * Sets a value at a deeply nested key in an object using dot/bracket notation path.\n * Creates intermediate objects and arrays as needed.\n *\n * @template T\n * @param {T} obj - The object to modify.\n * @param {string} path - String path using dot and/or bracket notation (e.g., 'user.friends[0].name').\n * @param {any} value - The value to set at the path.\n * @returns {T} The modified object.\n */\nexport function setValueByPath<T extends object>(obj: T, path: string, value: any): T {\n if (!obj || typeof obj !== 'object') return obj;\n\n // Convert path like \"a.b[0].c\" into [\"a\", \"b\", \"0\", \"c\"]\n const parts = path\n .replace(/\\[(\\d+)\\]/g, '.$1') // convert [0] to .0\n .split('.')\n .filter(Boolean); // remove empty strings\n\n // Handle empty path\n if (parts.length === 0) return obj;\n\n let current: any = obj;\n\n // Navigate to the parent of the target property\n for (let i = 0; i < parts.length - 1; i++) {\n const key = parts[i];\n const isArrayIndex = !isNaN(Number(parts[i + 1]));\n\n if (current[key] === undefined) {\n // Create intermediate object or array based on next key type\n current[key] = isArrayIndex ? [] : {};\n }\n\n current = current[key];\n }\n\n // Set the value at the final key\n const finalKey = parts[parts.length - 1];\n current[finalKey] = value;\n\n return obj;\n}\n\n/**\n * Performs a deep equality check between two objects.\n *\n * @param {any} a - First value to compare.\n * @param {any} b - Second value to compare.\n * @returns {boolean} True if values are deeply equal.\n */\nexport function isEqual(a: any, b: any): boolean {\n // Check if primitives or references to the same object\n if (a === b) return true;\n\n // Check if either is null/undefined or not an object\n if (a == null || b == null || typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n\n // Handle Date objects\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // If one is Date but the other isn't\n if (a instanceof Date || b instanceof Date) {\n return false;\n }\n\n // Handle arrays\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n\n // Check each element\n for (let i = 0; i < a.length; i++) {\n if (!isEqual(a[i], b[i])) return false;\n }\n\n return true;\n }\n\n // If one is Array but the other isn't\n if (Array.isArray(a) || Array.isArray(b)) {\n return false;\n }\n\n // Compare object keys\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n // Check if every key in A exists in B and has the same value\n return keysA.every(key => Object.prototype.hasOwnProperty.call(b, key) && isEqual(a[key], b[key]));\n}\n\n/**\n * Filters object properties based on a predicate function.\n *\n * @template T\n * @param {T} obj - The source object.\n * @param {(value: any, key: string, obj: T) => boolean} predicate - Filter function.\n * @returns {Partial<T>} New object with filtered properties.\n */\nexport function filterObject<T extends object>(\n obj: T,\n predicate: (value: any, key: string, obj: T) => boolean\n): Partial<T> {\n return Object.fromEntries(Object.entries(obj).filter(([key, value]) => predicate(value, key, obj))) as Partial<T>;\n}\n\n/**\n * Maps object values to new values using a mapping function.\n *\n * @template T\n * @template U\n * @param {T} obj - The source object.\n * @param {(value: any, key: string, obj: T) => U} mapFn - Mapping function.\n * @returns {Record<keyof T, U>} New object with mapped values.\n */\nexport function mapObject<T extends object, U>(\n obj: T,\n mapFn: (value: any, key: string, obj: T) => U\n): Record<keyof T, U> {\n return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, mapFn(value, key, obj)])) as Record<\n keyof T,\n U\n >;\n}\n\n/**\n * Recursively freezes an object and all its properties.\n * Makes an object immutable.\n *\n * @template T\n * @param {T} obj - The object to freeze.\n * @returns {Readonly<T>} The frozen object.\n */\nexport function deepFreeze<T extends object>(obj: T): Readonly<T> {\n // Freeze primitive properties\n Object.freeze(obj);\n\n // Recursively freeze nested objects\n for (const prop of Object.getOwnPropertyNames(obj)) {\n const value = (obj as any)[prop];\n if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {\n deepFreeze(value);\n }\n }\n\n return obj;\n}\n\n/**\n * Safely checks if a value is an object (not null, not array).\n *\n * @param {unknown} value - Value to check.\n * @returns {boolean} True if value is a non-null, non-array object.\n */\nexport function isObject(value: unknown): value is Record<string, any> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Gets all paths in an object using dot notation.\n *\n * @param {Record<string, any>} obj - Object to analyze.\n * @param {string} [parentPath=\"\"] - Internal param for recursion.\n * @returns {string[]} Array of all paths in dot notation.\n */\nexport function getAllPaths(obj: Record<string, any>, parentPath: string = ''): string[] {\n if (!isObject(obj)) return [];\n\n return Object.entries(obj).flatMap(([key, value]) => {\n const currentPath = parentPath ? `${parentPath}.${key}` : key;\n\n if (isObject(value)) {\n return [currentPath, ...getAllPaths(value, currentPath)];\n }\n\n return [currentPath];\n });\n}\n"]}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for parsing and validating request parameters.
|
|
3
|
-
*/
|
|
4
|
-
export interface ValidationOptions {
|
|
5
|
-
/** Whether to throw an error on validation failure */
|
|
6
|
-
throwOnError?: boolean;
|
|
7
|
-
/** Custom error message for validation failures */
|
|
8
|
-
errorMessage?: string;
|
|
9
|
-
/** Default value to use if parameter is missing */
|
|
10
|
-
defaultValue?: any;
|
|
11
|
-
/** Whether the parameter is required */
|
|
12
|
-
required?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Result of a parameter validation operation.
|
|
16
|
-
*/
|
|
17
|
-
export interface ValidationResult<T> {
|
|
18
|
-
/** Whether validation was successful */
|
|
19
|
-
isValid: boolean;
|
|
20
|
-
/** The validated and potentially transformed value */
|
|
21
|
-
value: T | null;
|
|
22
|
-
/** Error message if validation failed */
|
|
23
|
-
error?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Safely parses a string parameter to a number.
|
|
27
|
-
*
|
|
28
|
-
* @param value - String value to parse
|
|
29
|
-
* @param options - Validation options
|
|
30
|
-
* @returns Validation result containing the parsed number or error
|
|
31
|
-
*/
|
|
32
|
-
export declare function parseNumberParam(value: string | undefined, options?: ValidationOptions): ValidationResult<number>;
|
|
33
|
-
/**
|
|
34
|
-
* Safely parses a string parameter to a boolean.
|
|
35
|
-
*
|
|
36
|
-
* @param value - String value to parse
|
|
37
|
-
* @param options - Validation options
|
|
38
|
-
* @returns Validation result containing the parsed boolean or error
|
|
39
|
-
*/
|
|
40
|
-
export declare function parseBooleanParam(value: string | undefined, options?: ValidationOptions): ValidationResult<boolean>;
|
|
41
|
-
/**
|
|
42
|
-
* Extracts pagination parameters from request query parameters.
|
|
43
|
-
*
|
|
44
|
-
* @param query - Query parameters object
|
|
45
|
-
* @param defaultPage - Default page number if not specified (defaults to 1)
|
|
46
|
-
* @param defaultLimit - Default per page size if not specified (defaults to 20)
|
|
47
|
-
* @param maxLimitSize - Maximum allowed per page size (defaults to 100)
|
|
48
|
-
* @returns Object containing validated page and limit
|
|
49
|
-
*/
|
|
50
|
-
export declare function extractPaginationParams(query: Record<string, string | string[]>, defaultPage?: number, defaultLimit?: number, maxLimitSize?: number): {
|
|
51
|
-
page: number;
|
|
52
|
-
limit: number;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Extracts sorting parameters from request query parameters.
|
|
56
|
-
*
|
|
57
|
-
* @param query - Query parameters object
|
|
58
|
-
* @param allowedFields - Array of field names that are allowed to be sorted
|
|
59
|
-
* @param defaultSort - Default sort configuration if not specified
|
|
60
|
-
* @returns Object containing sort field and direction
|
|
61
|
-
*/
|
|
62
|
-
export declare function extractSortParams(query: Record<string, string | string[]>, allowedFields: string[], defaultSort?: {
|
|
63
|
-
sortBy: string;
|
|
64
|
-
sortOrder: 'asc' | 'desc';
|
|
65
|
-
}): {
|
|
66
|
-
sortBy: string;
|
|
67
|
-
sortOrder: 'asc' | 'desc';
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Extracts filter parameters from query parameters based on allowed filter fields.
|
|
71
|
-
*
|
|
72
|
-
* @param query - Query parameters object
|
|
73
|
-
* @param allowedFilters - Array of field names that are allowed to be used as filters
|
|
74
|
-
* @returns Object containing the filters as key-value pairs
|
|
75
|
-
*/
|
|
76
|
-
export declare function extractFilterParams(query: Record<string, string | string[]>, allowedFilters: string[]): Record<string, string | string[]>;
|
|
77
|
-
//# sourceMappingURL=request.utils.d.ts.map
|