utilitify-core 1.0.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 +21 -0
- package/README.md +338 -0
- package/dist/async.cjs +25 -0
- package/dist/async.cjs.map +1 -0
- package/dist/async.d.cts +104 -0
- package/dist/async.d.ts +104 -0
- package/dist/async.js +4 -0
- package/dist/async.js.map +1 -0
- package/dist/chunk-2ICNRTSN.cjs +346 -0
- package/dist/chunk-2ICNRTSN.cjs.map +1 -0
- package/dist/chunk-3DPF72DY.js +170 -0
- package/dist/chunk-3DPF72DY.js.map +1 -0
- package/dist/chunk-4CV4JOE5.js +24 -0
- package/dist/chunk-4CV4JOE5.js.map +1 -0
- package/dist/chunk-4SLYNSLH.cjs +783 -0
- package/dist/chunk-4SLYNSLH.cjs.map +1 -0
- package/dist/chunk-5WP7DWCG.js +1285 -0
- package/dist/chunk-5WP7DWCG.js.map +1 -0
- package/dist/chunk-BMQ6YPKV.js +876 -0
- package/dist/chunk-BMQ6YPKV.js.map +1 -0
- package/dist/chunk-BZCMWUKS.cjs +479 -0
- package/dist/chunk-BZCMWUKS.cjs.map +1 -0
- package/dist/chunk-C5R744DY.cjs +173 -0
- package/dist/chunk-C5R744DY.cjs.map +1 -0
- package/dist/chunk-C75J62CV.cjs +913 -0
- package/dist/chunk-C75J62CV.cjs.map +1 -0
- package/dist/chunk-CZLDE2OZ.cjs +28 -0
- package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
- package/dist/chunk-DSMB6AF6.cjs +193 -0
- package/dist/chunk-DSMB6AF6.cjs.map +1 -0
- package/dist/chunk-ETWGPOPY.js +426 -0
- package/dist/chunk-ETWGPOPY.js.map +1 -0
- package/dist/chunk-FQBPVN63.cjs +403 -0
- package/dist/chunk-FQBPVN63.cjs.map +1 -0
- package/dist/chunk-G4GYQGTW.cjs +178 -0
- package/dist/chunk-G4GYQGTW.cjs.map +1 -0
- package/dist/chunk-GFDMZDMI.js +486 -0
- package/dist/chunk-GFDMZDMI.js.map +1 -0
- package/dist/chunk-HOTOYIPB.js +171 -0
- package/dist/chunk-HOTOYIPB.js.map +1 -0
- package/dist/chunk-HYADH4ZX.js +176 -0
- package/dist/chunk-HYADH4ZX.js.map +1 -0
- package/dist/chunk-JBN7C5WE.js +255 -0
- package/dist/chunk-JBN7C5WE.js.map +1 -0
- package/dist/chunk-JNCTPFTD.cjs +25 -0
- package/dist/chunk-JNCTPFTD.cjs.map +1 -0
- package/dist/chunk-N3BH3BV7.js +21 -0
- package/dist/chunk-N3BH3BV7.js.map +1 -0
- package/dist/chunk-NFPGAVRQ.js +749 -0
- package/dist/chunk-NFPGAVRQ.js.map +1 -0
- package/dist/chunk-OFFRGRBN.cjs +1332 -0
- package/dist/chunk-OFFRGRBN.cjs.map +1 -0
- package/dist/chunk-OZLKYIZL.cjs +490 -0
- package/dist/chunk-OZLKYIZL.cjs.map +1 -0
- package/dist/chunk-P3NUK46X.js +145 -0
- package/dist/chunk-P3NUK46X.js.map +1 -0
- package/dist/chunk-P7P2B7ZI.cjs +429 -0
- package/dist/chunk-P7P2B7ZI.cjs.map +1 -0
- package/dist/chunk-PB6SKSJN.cjs +150 -0
- package/dist/chunk-PB6SKSJN.cjs.map +1 -0
- package/dist/chunk-R3IXCJR7.js +378 -0
- package/dist/chunk-R3IXCJR7.js.map +1 -0
- package/dist/chunk-SD6P3WEJ.js +324 -0
- package/dist/chunk-SD6P3WEJ.js.map +1 -0
- package/dist/chunk-YSCHP26P.js +451 -0
- package/dist/chunk-YSCHP26P.js.map +1 -0
- package/dist/chunk-ZLMPRPCY.cjs +274 -0
- package/dist/chunk-ZLMPRPCY.cjs.map +1 -0
- package/dist/common-CBDYNJeh.d.cts +48 -0
- package/dist/common-CBDYNJeh.d.ts +48 -0
- package/dist/constants.cjs +42 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +60 -0
- package/dist/constants.d.ts +60 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/country/index.cjs +154 -0
- package/dist/country/index.cjs.map +1 -0
- package/dist/country/index.d.cts +1 -0
- package/dist/country/index.d.ts +1 -0
- package/dist/country/index.js +5 -0
- package/dist/country/index.js.map +1 -0
- package/dist/date/index.cjs +117 -0
- package/dist/date/index.cjs.map +1 -0
- package/dist/date/index.d.cts +283 -0
- package/dist/date/index.d.ts +283 -0
- package/dist/date/index.js +4 -0
- package/dist/date/index.js.map +1 -0
- package/dist/environment/index.cjs +73 -0
- package/dist/environment/index.cjs.map +1 -0
- package/dist/environment/index.d.cts +127 -0
- package/dist/environment/index.d.ts +127 -0
- package/dist/environment/index.js +4 -0
- package/dist/environment/index.js.map +1 -0
- package/dist/form/index.cjs +81 -0
- package/dist/form/index.cjs.map +1 -0
- package/dist/form/index.d.cts +227 -0
- package/dist/form/index.d.ts +227 -0
- package/dist/form/index.js +4 -0
- package/dist/form/index.js.map +1 -0
- package/dist/i18n.cjs +37 -0
- package/dist/i18n.cjs.map +1 -0
- package/dist/i18n.d.cts +102 -0
- package/dist/i18n.d.ts +102 -0
- package/dist/i18n.js +4 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index-BXBmBHyL.d.ts +718 -0
- package/dist/index-BYsUCP3u.d.cts +718 -0
- package/dist/index-Cl26FrAZ.d.cts +362 -0
- package/dist/index-Cl26FrAZ.d.ts +362 -0
- package/dist/index.cjs +1265 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +205 -0
- package/dist/index.d.ts +205 -0
- package/dist/index.js +277 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.cjs +13 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +84 -0
- package/dist/schema.d.ts +84 -0
- package/dist/schema.js +4 -0
- package/dist/schema.js.map +1 -0
- package/dist/security/index.cjs +94 -0
- package/dist/security/index.cjs.map +1 -0
- package/dist/security/index.d.cts +216 -0
- package/dist/security/index.d.ts +216 -0
- package/dist/security/index.js +5 -0
- package/dist/security/index.js.map +1 -0
- package/dist/string/index.cjs +153 -0
- package/dist/string/index.cjs.map +1 -0
- package/dist/string/index.d.cts +471 -0
- package/dist/string/index.d.ts +471 -0
- package/dist/string/index.js +4 -0
- package/dist/string/index.js.map +1 -0
- package/dist/transform/index.cjs +105 -0
- package/dist/transform/index.cjs.map +1 -0
- package/dist/transform/index.d.cts +271 -0
- package/dist/transform/index.d.ts +271 -0
- package/dist/transform/index.js +4 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/validators/index.cjs +195 -0
- package/dist/validators/index.cjs.map +1 -0
- package/dist/validators/index.d.cts +2 -0
- package/dist/validators/index.d.ts +2 -0
- package/dist/validators/index.js +6 -0
- package/dist/validators/index.js.map +1 -0
- package/package.json +229 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge options
|
|
3
|
+
*/
|
|
4
|
+
interface MergeOptions {
|
|
5
|
+
/** How to merge arrays: 'concat', 'replace', or 'union' */
|
|
6
|
+
arrayMerge?: 'concat' | 'replace' | 'union';
|
|
7
|
+
/** Clone objects instead of mutating */
|
|
8
|
+
clone?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Deep merge multiple objects
|
|
12
|
+
*
|
|
13
|
+
* @param objects - Objects to merge
|
|
14
|
+
* @returns Merged object
|
|
15
|
+
* @since 1.0.0
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* deepMerge({ a: 1, b: { c: 2 } }, { b: { d: 3 } });
|
|
20
|
+
* // { a: 1, b: { c: 2, d: 3 } }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare function deepMerge<T extends object>(...objects: Partial<T>[]): T;
|
|
24
|
+
/**
|
|
25
|
+
* Deep merge with options
|
|
26
|
+
*
|
|
27
|
+
* @param options - Merge options
|
|
28
|
+
* @param objects - Objects to merge
|
|
29
|
+
* @returns Merged object
|
|
30
|
+
* @since 1.0.0
|
|
31
|
+
*/
|
|
32
|
+
declare function deepMergeWith<T extends object>(options: MergeOptions, ...objects: Partial<T>[]): T;
|
|
33
|
+
/**
|
|
34
|
+
* Deep clone an object
|
|
35
|
+
*
|
|
36
|
+
* @param obj - Object to clone
|
|
37
|
+
* @returns Cloned object
|
|
38
|
+
* @since 1.0.0
|
|
39
|
+
*/
|
|
40
|
+
declare function cloneDeep<T>(obj: T): T;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Flatten options
|
|
44
|
+
*/
|
|
45
|
+
interface FlattenOptions {
|
|
46
|
+
/** Delimiter for keys (default: '.') */
|
|
47
|
+
delimiter?: string;
|
|
48
|
+
/** Maximum depth to flatten */
|
|
49
|
+
maxDepth?: number;
|
|
50
|
+
/** Whether to flatten arrays */
|
|
51
|
+
flattenArrays?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Flatten a nested object
|
|
55
|
+
*
|
|
56
|
+
* @param obj - Object to flatten
|
|
57
|
+
* @param options - Flatten options
|
|
58
|
+
* @returns Flattened object
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* flattenObject({ a: { b: { c: 1 } }, d: 2 });
|
|
63
|
+
* // { 'a.b.c': 1, 'd': 2 }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function flattenObject<T extends object>(obj: T, options?: FlattenOptions): Record<string, unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* Unflatten a flattened object
|
|
69
|
+
*
|
|
70
|
+
* @param obj - Flattened object
|
|
71
|
+
* @param options - Options
|
|
72
|
+
* @returns Nested object
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* unflattenObject({ 'a.b.c': 1, 'd': 2 });
|
|
77
|
+
* // { a: { b: { c: 1 } }, d: 2 }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare function unflattenObject<T extends object>(obj: Record<string, unknown>, options?: FlattenOptions): T;
|
|
81
|
+
/**
|
|
82
|
+
* Get value at path
|
|
83
|
+
*
|
|
84
|
+
* @param obj - Object
|
|
85
|
+
* @param path - Dot-notation path
|
|
86
|
+
* @param defaultValue - Default value if not found
|
|
87
|
+
* @returns Value at path
|
|
88
|
+
*/
|
|
89
|
+
declare function get<T = unknown>(obj: Record<string, unknown>, path: string | string[], defaultValue?: T): T | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Set value at path
|
|
92
|
+
*
|
|
93
|
+
* @param obj - Object
|
|
94
|
+
* @param path - Dot-notation path
|
|
95
|
+
* @param value - Value to set
|
|
96
|
+
* @returns Modified object
|
|
97
|
+
*/
|
|
98
|
+
declare function set<T extends object>(obj: T, path: string | string[], value: unknown): T;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Pick specified keys from object
|
|
102
|
+
*
|
|
103
|
+
* @param obj - Source object
|
|
104
|
+
* @param keys - Keys to pick
|
|
105
|
+
* @returns New object with only specified keys
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* pick({ a: 1, b: 2, c: 3 }, ['a', 'c']);
|
|
110
|
+
* // { a: 1, c: 3 }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
114
|
+
/**
|
|
115
|
+
* Omit specified keys from object
|
|
116
|
+
*
|
|
117
|
+
* @param obj - Source object
|
|
118
|
+
* @param keys - Keys to omit
|
|
119
|
+
* @returns New object without specified keys
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* omit({ a: 1, b: 2, c: 3 }, ['b']);
|
|
124
|
+
* // { a: 1, c: 3 }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
128
|
+
/**
|
|
129
|
+
* Pick keys by predicate function
|
|
130
|
+
*
|
|
131
|
+
* @param obj - Source object
|
|
132
|
+
* @param predicate - Function to test each entry
|
|
133
|
+
* @returns New object with matching entries
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* pickBy({ a: 1, b: null, c: 3 }, value => value !== null);
|
|
138
|
+
* // { a: 1, c: 3 }
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
declare function pickBy<T extends object>(obj: T, predicate: (value: unknown, key: string) => boolean): Partial<T>;
|
|
142
|
+
/**
|
|
143
|
+
* Omit keys by predicate function
|
|
144
|
+
*
|
|
145
|
+
* @param obj - Source object
|
|
146
|
+
* @param predicate - Function to test each entry
|
|
147
|
+
* @returns New object without matching entries
|
|
148
|
+
*/
|
|
149
|
+
declare function omitBy<T extends object>(obj: T, predicate: (value: unknown, key: string) => boolean): Partial<T>;
|
|
150
|
+
/**
|
|
151
|
+
* Remove null and undefined values
|
|
152
|
+
*
|
|
153
|
+
* @param obj - Source object
|
|
154
|
+
* @returns Object without null/undefined values
|
|
155
|
+
*/
|
|
156
|
+
declare function compact<T extends object>(obj: T): Partial<T>;
|
|
157
|
+
/**
|
|
158
|
+
* Remove falsy values (null, undefined, '', 0, false)
|
|
159
|
+
*
|
|
160
|
+
* @param obj - Source object
|
|
161
|
+
* @returns Object without falsy values
|
|
162
|
+
*/
|
|
163
|
+
declare function compactDeep<T extends object>(obj: T): Partial<T>;
|
|
164
|
+
/**
|
|
165
|
+
* Map object values
|
|
166
|
+
*
|
|
167
|
+
* @param obj - Source object
|
|
168
|
+
* @param fn - Mapping function
|
|
169
|
+
* @returns New object with mapped values
|
|
170
|
+
*/
|
|
171
|
+
declare function mapValues<T extends object, R>(obj: T, fn: (value: T[keyof T], key: keyof T) => R): Record<keyof T, R>;
|
|
172
|
+
/**
|
|
173
|
+
* Map object keys
|
|
174
|
+
*
|
|
175
|
+
* @param obj - Source object
|
|
176
|
+
* @param fn - Mapping function
|
|
177
|
+
* @returns New object with mapped keys
|
|
178
|
+
*/
|
|
179
|
+
declare function mapKeys<T extends object>(obj: T, fn: (key: string, value: unknown) => string): Record<string, unknown>;
|
|
180
|
+
/**
|
|
181
|
+
* Invert object (swap keys and values)
|
|
182
|
+
*
|
|
183
|
+
* @param obj - Source object
|
|
184
|
+
* @returns Inverted object
|
|
185
|
+
*/
|
|
186
|
+
declare function invert<T extends Record<string, string | number>>(obj: T): Record<string, string>;
|
|
187
|
+
/**
|
|
188
|
+
* Get all keys including nested (as paths)
|
|
189
|
+
*
|
|
190
|
+
* @param obj - Source object
|
|
191
|
+
* @param prefix - Key prefix
|
|
192
|
+
* @returns Array of all paths
|
|
193
|
+
*/
|
|
194
|
+
declare function getAllKeys(obj: Record<string, unknown>, prefix?: string): string[];
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Sanitization options
|
|
198
|
+
*/
|
|
199
|
+
interface SanitizeOptions {
|
|
200
|
+
/** Strip HTML tags */
|
|
201
|
+
stripHtml?: boolean;
|
|
202
|
+
/** Escape HTML entities */
|
|
203
|
+
escapeHtml?: boolean;
|
|
204
|
+
/** Trim whitespace */
|
|
205
|
+
trim?: boolean;
|
|
206
|
+
/** Remove null bytes */
|
|
207
|
+
removeNullBytes?: boolean;
|
|
208
|
+
/** Maximum string length */
|
|
209
|
+
maxLength?: number;
|
|
210
|
+
/** Allowed HTML tags (if not stripping all) */
|
|
211
|
+
allowedTags?: string[];
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Sanitize string input
|
|
215
|
+
*
|
|
216
|
+
* @param input - String to sanitize
|
|
217
|
+
* @param options - Sanitization options
|
|
218
|
+
* @returns Sanitized string
|
|
219
|
+
* @since 1.0.0
|
|
220
|
+
*/
|
|
221
|
+
declare function sanitizeString(input: string, options?: SanitizeOptions): string;
|
|
222
|
+
/**
|
|
223
|
+
* Strip HTML tags from string
|
|
224
|
+
*
|
|
225
|
+
* @param html - HTML string
|
|
226
|
+
* @param allowedTags - Tags to keep
|
|
227
|
+
* @returns Cleaned string
|
|
228
|
+
* @since 1.0.0
|
|
229
|
+
*/
|
|
230
|
+
declare function stripHtml(html: string, allowedTags?: string[]): string;
|
|
231
|
+
/**
|
|
232
|
+
* Escape HTML entities
|
|
233
|
+
*
|
|
234
|
+
* @param str - String to escape
|
|
235
|
+
* @returns Escaped string
|
|
236
|
+
* @since 1.0.0
|
|
237
|
+
*/
|
|
238
|
+
declare function escapeHtml(str: string): string;
|
|
239
|
+
/**
|
|
240
|
+
* Unescape HTML entities
|
|
241
|
+
*
|
|
242
|
+
* @param str - String to unescape
|
|
243
|
+
* @returns Unescaped string
|
|
244
|
+
* @since 1.0.0
|
|
245
|
+
*/
|
|
246
|
+
declare function unescapeHtml(str: string): string;
|
|
247
|
+
/**
|
|
248
|
+
* Sanitize object recursively
|
|
249
|
+
*
|
|
250
|
+
* @param obj - Object to sanitize
|
|
251
|
+
* @param options - Sanitization options
|
|
252
|
+
* @returns Sanitized object
|
|
253
|
+
* @since 1.0.0
|
|
254
|
+
*/
|
|
255
|
+
declare function sanitizeObject<T extends object>(obj: T, options?: SanitizeOptions): T;
|
|
256
|
+
/**
|
|
257
|
+
* Sanitize for URL
|
|
258
|
+
*
|
|
259
|
+
* @param str - String to sanitize
|
|
260
|
+
* @returns URL-safe string
|
|
261
|
+
*/
|
|
262
|
+
declare function sanitizeUrl(str: string): string;
|
|
263
|
+
/**
|
|
264
|
+
* Remove control characters
|
|
265
|
+
*
|
|
266
|
+
* @param str - String to clean
|
|
267
|
+
* @returns Cleaned string
|
|
268
|
+
*/
|
|
269
|
+
declare function removeControlChars(str: string): string;
|
|
270
|
+
|
|
271
|
+
export { type FlattenOptions, type MergeOptions, type SanitizeOptions, cloneDeep, compact, compactDeep, deepMerge, deepMergeWith, escapeHtml, flattenObject, get, getAllKeys, invert, mapKeys, mapValues, omit, omitBy, pick, pickBy, removeControlChars, sanitizeObject, sanitizeString, sanitizeUrl, set, stripHtml, unescapeHtml, unflattenObject };
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge options
|
|
3
|
+
*/
|
|
4
|
+
interface MergeOptions {
|
|
5
|
+
/** How to merge arrays: 'concat', 'replace', or 'union' */
|
|
6
|
+
arrayMerge?: 'concat' | 'replace' | 'union';
|
|
7
|
+
/** Clone objects instead of mutating */
|
|
8
|
+
clone?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Deep merge multiple objects
|
|
12
|
+
*
|
|
13
|
+
* @param objects - Objects to merge
|
|
14
|
+
* @returns Merged object
|
|
15
|
+
* @since 1.0.0
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* deepMerge({ a: 1, b: { c: 2 } }, { b: { d: 3 } });
|
|
20
|
+
* // { a: 1, b: { c: 2, d: 3 } }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare function deepMerge<T extends object>(...objects: Partial<T>[]): T;
|
|
24
|
+
/**
|
|
25
|
+
* Deep merge with options
|
|
26
|
+
*
|
|
27
|
+
* @param options - Merge options
|
|
28
|
+
* @param objects - Objects to merge
|
|
29
|
+
* @returns Merged object
|
|
30
|
+
* @since 1.0.0
|
|
31
|
+
*/
|
|
32
|
+
declare function deepMergeWith<T extends object>(options: MergeOptions, ...objects: Partial<T>[]): T;
|
|
33
|
+
/**
|
|
34
|
+
* Deep clone an object
|
|
35
|
+
*
|
|
36
|
+
* @param obj - Object to clone
|
|
37
|
+
* @returns Cloned object
|
|
38
|
+
* @since 1.0.0
|
|
39
|
+
*/
|
|
40
|
+
declare function cloneDeep<T>(obj: T): T;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Flatten options
|
|
44
|
+
*/
|
|
45
|
+
interface FlattenOptions {
|
|
46
|
+
/** Delimiter for keys (default: '.') */
|
|
47
|
+
delimiter?: string;
|
|
48
|
+
/** Maximum depth to flatten */
|
|
49
|
+
maxDepth?: number;
|
|
50
|
+
/** Whether to flatten arrays */
|
|
51
|
+
flattenArrays?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Flatten a nested object
|
|
55
|
+
*
|
|
56
|
+
* @param obj - Object to flatten
|
|
57
|
+
* @param options - Flatten options
|
|
58
|
+
* @returns Flattened object
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* flattenObject({ a: { b: { c: 1 } }, d: 2 });
|
|
63
|
+
* // { 'a.b.c': 1, 'd': 2 }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function flattenObject<T extends object>(obj: T, options?: FlattenOptions): Record<string, unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* Unflatten a flattened object
|
|
69
|
+
*
|
|
70
|
+
* @param obj - Flattened object
|
|
71
|
+
* @param options - Options
|
|
72
|
+
* @returns Nested object
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* unflattenObject({ 'a.b.c': 1, 'd': 2 });
|
|
77
|
+
* // { a: { b: { c: 1 } }, d: 2 }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare function unflattenObject<T extends object>(obj: Record<string, unknown>, options?: FlattenOptions): T;
|
|
81
|
+
/**
|
|
82
|
+
* Get value at path
|
|
83
|
+
*
|
|
84
|
+
* @param obj - Object
|
|
85
|
+
* @param path - Dot-notation path
|
|
86
|
+
* @param defaultValue - Default value if not found
|
|
87
|
+
* @returns Value at path
|
|
88
|
+
*/
|
|
89
|
+
declare function get<T = unknown>(obj: Record<string, unknown>, path: string | string[], defaultValue?: T): T | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Set value at path
|
|
92
|
+
*
|
|
93
|
+
* @param obj - Object
|
|
94
|
+
* @param path - Dot-notation path
|
|
95
|
+
* @param value - Value to set
|
|
96
|
+
* @returns Modified object
|
|
97
|
+
*/
|
|
98
|
+
declare function set<T extends object>(obj: T, path: string | string[], value: unknown): T;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Pick specified keys from object
|
|
102
|
+
*
|
|
103
|
+
* @param obj - Source object
|
|
104
|
+
* @param keys - Keys to pick
|
|
105
|
+
* @returns New object with only specified keys
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* pick({ a: 1, b: 2, c: 3 }, ['a', 'c']);
|
|
110
|
+
* // { a: 1, c: 3 }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
114
|
+
/**
|
|
115
|
+
* Omit specified keys from object
|
|
116
|
+
*
|
|
117
|
+
* @param obj - Source object
|
|
118
|
+
* @param keys - Keys to omit
|
|
119
|
+
* @returns New object without specified keys
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* omit({ a: 1, b: 2, c: 3 }, ['b']);
|
|
124
|
+
* // { a: 1, c: 3 }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
128
|
+
/**
|
|
129
|
+
* Pick keys by predicate function
|
|
130
|
+
*
|
|
131
|
+
* @param obj - Source object
|
|
132
|
+
* @param predicate - Function to test each entry
|
|
133
|
+
* @returns New object with matching entries
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* pickBy({ a: 1, b: null, c: 3 }, value => value !== null);
|
|
138
|
+
* // { a: 1, c: 3 }
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
declare function pickBy<T extends object>(obj: T, predicate: (value: unknown, key: string) => boolean): Partial<T>;
|
|
142
|
+
/**
|
|
143
|
+
* Omit keys by predicate function
|
|
144
|
+
*
|
|
145
|
+
* @param obj - Source object
|
|
146
|
+
* @param predicate - Function to test each entry
|
|
147
|
+
* @returns New object without matching entries
|
|
148
|
+
*/
|
|
149
|
+
declare function omitBy<T extends object>(obj: T, predicate: (value: unknown, key: string) => boolean): Partial<T>;
|
|
150
|
+
/**
|
|
151
|
+
* Remove null and undefined values
|
|
152
|
+
*
|
|
153
|
+
* @param obj - Source object
|
|
154
|
+
* @returns Object without null/undefined values
|
|
155
|
+
*/
|
|
156
|
+
declare function compact<T extends object>(obj: T): Partial<T>;
|
|
157
|
+
/**
|
|
158
|
+
* Remove falsy values (null, undefined, '', 0, false)
|
|
159
|
+
*
|
|
160
|
+
* @param obj - Source object
|
|
161
|
+
* @returns Object without falsy values
|
|
162
|
+
*/
|
|
163
|
+
declare function compactDeep<T extends object>(obj: T): Partial<T>;
|
|
164
|
+
/**
|
|
165
|
+
* Map object values
|
|
166
|
+
*
|
|
167
|
+
* @param obj - Source object
|
|
168
|
+
* @param fn - Mapping function
|
|
169
|
+
* @returns New object with mapped values
|
|
170
|
+
*/
|
|
171
|
+
declare function mapValues<T extends object, R>(obj: T, fn: (value: T[keyof T], key: keyof T) => R): Record<keyof T, R>;
|
|
172
|
+
/**
|
|
173
|
+
* Map object keys
|
|
174
|
+
*
|
|
175
|
+
* @param obj - Source object
|
|
176
|
+
* @param fn - Mapping function
|
|
177
|
+
* @returns New object with mapped keys
|
|
178
|
+
*/
|
|
179
|
+
declare function mapKeys<T extends object>(obj: T, fn: (key: string, value: unknown) => string): Record<string, unknown>;
|
|
180
|
+
/**
|
|
181
|
+
* Invert object (swap keys and values)
|
|
182
|
+
*
|
|
183
|
+
* @param obj - Source object
|
|
184
|
+
* @returns Inverted object
|
|
185
|
+
*/
|
|
186
|
+
declare function invert<T extends Record<string, string | number>>(obj: T): Record<string, string>;
|
|
187
|
+
/**
|
|
188
|
+
* Get all keys including nested (as paths)
|
|
189
|
+
*
|
|
190
|
+
* @param obj - Source object
|
|
191
|
+
* @param prefix - Key prefix
|
|
192
|
+
* @returns Array of all paths
|
|
193
|
+
*/
|
|
194
|
+
declare function getAllKeys(obj: Record<string, unknown>, prefix?: string): string[];
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Sanitization options
|
|
198
|
+
*/
|
|
199
|
+
interface SanitizeOptions {
|
|
200
|
+
/** Strip HTML tags */
|
|
201
|
+
stripHtml?: boolean;
|
|
202
|
+
/** Escape HTML entities */
|
|
203
|
+
escapeHtml?: boolean;
|
|
204
|
+
/** Trim whitespace */
|
|
205
|
+
trim?: boolean;
|
|
206
|
+
/** Remove null bytes */
|
|
207
|
+
removeNullBytes?: boolean;
|
|
208
|
+
/** Maximum string length */
|
|
209
|
+
maxLength?: number;
|
|
210
|
+
/** Allowed HTML tags (if not stripping all) */
|
|
211
|
+
allowedTags?: string[];
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Sanitize string input
|
|
215
|
+
*
|
|
216
|
+
* @param input - String to sanitize
|
|
217
|
+
* @param options - Sanitization options
|
|
218
|
+
* @returns Sanitized string
|
|
219
|
+
* @since 1.0.0
|
|
220
|
+
*/
|
|
221
|
+
declare function sanitizeString(input: string, options?: SanitizeOptions): string;
|
|
222
|
+
/**
|
|
223
|
+
* Strip HTML tags from string
|
|
224
|
+
*
|
|
225
|
+
* @param html - HTML string
|
|
226
|
+
* @param allowedTags - Tags to keep
|
|
227
|
+
* @returns Cleaned string
|
|
228
|
+
* @since 1.0.0
|
|
229
|
+
*/
|
|
230
|
+
declare function stripHtml(html: string, allowedTags?: string[]): string;
|
|
231
|
+
/**
|
|
232
|
+
* Escape HTML entities
|
|
233
|
+
*
|
|
234
|
+
* @param str - String to escape
|
|
235
|
+
* @returns Escaped string
|
|
236
|
+
* @since 1.0.0
|
|
237
|
+
*/
|
|
238
|
+
declare function escapeHtml(str: string): string;
|
|
239
|
+
/**
|
|
240
|
+
* Unescape HTML entities
|
|
241
|
+
*
|
|
242
|
+
* @param str - String to unescape
|
|
243
|
+
* @returns Unescaped string
|
|
244
|
+
* @since 1.0.0
|
|
245
|
+
*/
|
|
246
|
+
declare function unescapeHtml(str: string): string;
|
|
247
|
+
/**
|
|
248
|
+
* Sanitize object recursively
|
|
249
|
+
*
|
|
250
|
+
* @param obj - Object to sanitize
|
|
251
|
+
* @param options - Sanitization options
|
|
252
|
+
* @returns Sanitized object
|
|
253
|
+
* @since 1.0.0
|
|
254
|
+
*/
|
|
255
|
+
declare function sanitizeObject<T extends object>(obj: T, options?: SanitizeOptions): T;
|
|
256
|
+
/**
|
|
257
|
+
* Sanitize for URL
|
|
258
|
+
*
|
|
259
|
+
* @param str - String to sanitize
|
|
260
|
+
* @returns URL-safe string
|
|
261
|
+
*/
|
|
262
|
+
declare function sanitizeUrl(str: string): string;
|
|
263
|
+
/**
|
|
264
|
+
* Remove control characters
|
|
265
|
+
*
|
|
266
|
+
* @param str - String to clean
|
|
267
|
+
* @returns Cleaned string
|
|
268
|
+
*/
|
|
269
|
+
declare function removeControlChars(str: string): string;
|
|
270
|
+
|
|
271
|
+
export { type FlattenOptions, type MergeOptions, type SanitizeOptions, cloneDeep, compact, compactDeep, deepMerge, deepMergeWith, escapeHtml, flattenObject, get, getAllKeys, invert, mapKeys, mapValues, omit, omitBy, pick, pickBy, removeControlChars, sanitizeObject, sanitizeString, sanitizeUrl, set, stripHtml, unescapeHtml, unflattenObject };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { cloneDeep, compact, compactDeep, deepMerge, deepMergeWith, escapeHtml, flattenObject, get, getAllKeys, invert, mapKeys, mapValues, omit, omitBy, pick, pickBy, removeControlChars, sanitizeObject, sanitizeString, sanitizeUrl, set, stripHtml, unescapeHtml, unflattenObject } from '../chunk-R3IXCJR7.js';
|
|
2
|
+
import '../chunk-4CV4JOE5.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|