@homer0/object-utils 6.0.2 → 6.0.4

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/dist/index.d.ts CHANGED
@@ -1,31 +1,26 @@
1
1
  /**
2
2
  * Creates a deep copy of a given object.
3
3
  *
4
- * @param target The object to copy.
5
- * @template T The type of the input object, which will be the same as the one
6
- * returned.
4
+ * @template T The type of the input object, which will be the same as the one returned.
5
+ * @param target The object to copy.
7
6
  */
8
7
  declare const copy: <T>(target: T) => T;
9
8
 
10
9
  /**
11
10
  * The callback that will be used to replace a key.
12
11
  *
13
- * @param substring The captured string to replace.
14
- * @param args The list of groups captured by the expression.
12
+ * @param substring The captured string to replace.
13
+ * @param args The list of groups captured by the expression.
15
14
  */
16
15
  type FormatKeysReplaceFn = (substring: string, ...args: string[]) => string;
17
16
  type FormatKeysOptions = {
18
- /**
19
- * The object to transform.
20
- */
17
+ /** The object to transform. */
21
18
  target: unknown;
22
- /**
23
- * A regular expression to match the keys to transform.
24
- */
19
+ /** A regular expression to match the keys to transform. */
25
20
  search: RegExp;
26
21
  /**
27
- * The callback that will be used to replace the matched substring. Think of `search` and
28
- * `replace` as the parameters of `String.replace`.
22
+ * The callback that will be used to replace the matched substring. Think of `search`
23
+ * and `replace` as the parameters of `String.replace`.
29
24
  */
30
25
  replace: FormatKeysReplaceFn;
31
26
  /**
@@ -33,12 +28,11 @@ type FormatKeysOptions = {
33
28
  * function will use all the keys from the object.
34
29
  */
35
30
  include?: string[];
36
- /**
37
- * A list of keys or paths where the transformation won't be made.
38
- */
31
+ /** A list of keys or paths where the transformation won't be made. */
39
32
  exclude?: string[];
40
33
  /**
41
- * The delimiter that will separate the path components for both `include` and `exclude`.
34
+ * The delimiter that will separate the path components for both `include` and
35
+ * `exclude`.
42
36
  */
43
37
  pathDelimiter?: string;
44
38
  };
@@ -47,57 +41,54 @@ type FormatKeysExtensionOptions = Omit<FormatKeysOptions, 'search' | 'replace'>;
47
41
  * Formats all the keys on an object using a way similar to `.replace(regexp, ...)` but
48
42
  * that also works recursively and with _"object paths"_.
49
43
  *
50
- * @param options The set of options to customize the transformation.
51
- * @template T The type of the returned object.
52
44
  * @example
53
- *
54
45
  * const target = {
55
- * prop_one: 'Charito!',
46
+ * prop_one: 'Charito!',
56
47
  * };
57
48
  * console.log(
58
- * formatKeys({
59
- * target,
60
- * // Find all the keys with snake case.
61
- * search: /([a-z])_([a-z])/g,
62
- * // Using the same .replace style callback, replace it with lower camel case.
63
- * replace: (_, firstLetter, secondLetter) => {
64
- * const newSecondLetter = secondLetter.toUpperCase();
65
- * return `${firstLetter}${newSecondLetter}`;
66
- * },
67
- * }),
49
+ * formatKeys({
50
+ * target,
51
+ * // Find all the keys with snake case.
52
+ * search: /([a-z])_([a-z])/g,
53
+ * // Using the same .replace style callback, replace it with lower camel case.
54
+ * replace: (_, firstLetter, secondLetter) => {
55
+ * const newSecondLetter = secondLetter.toUpperCase();
56
+ * return `${firstLetter}${newSecondLetter}`;
57
+ * },
58
+ * }),
68
59
  * );
69
60
  * // Will output { propOne: 'Charito!}.
70
61
  *
62
+ * @template T The type of the returned object.
63
+ * @param options The set of options to customize the transformation.
71
64
  */
72
65
  declare const formatKeys: <T = Record<string, unknown>>(options: FormatKeysOptions) => T;
73
66
 
74
67
  /**
75
- * A shorthand method for {@link formatKeys} that transforms the keys from `dash-case`
76
- * to `lowerCamelCase`.
68
+ * A shorthand method for {@link formatKeys} that transforms the keys from `dash-case` to
69
+ * `lowerCamelCase`.
77
70
  *
78
- * @param options The options to use.
79
- * @template T The type of the returned object.
71
+ * @template T The type of the returned object.
72
+ * @param options The options to use.
80
73
  */
81
74
  declare const dashToLowerCamelKeys: <T>(options: FormatKeysExtensionOptions) => T;
82
75
 
83
76
  /**
84
- * A shorthand method for {@link formatKeys} that transforms the keys from `dash-case`
85
- * to `snake_case`.
77
+ * A shorthand method for {@link formatKeys} that transforms the keys from `dash-case` to
78
+ * `snake_case`.
86
79
  *
87
- * @param options The options to use.
88
- * @template T The type of the returned object.
80
+ * @template T The type of the returned object.
81
+ * @param options The options to use.
89
82
  */
90
83
  declare const dashToSnakeKeys: <T>(options: FormatKeysExtensionOptions) => T;
91
84
 
92
85
  /**
93
- * Used in the {@link extract} function to specify a path for a property, or an "origin path"
94
- * and an "extraction path".
86
+ * Used in the {@link extract} function to specify a path for a property, or an "origin
87
+ * path" and an "extraction path".
95
88
  */
96
89
  type extractionPath = string | Record<string, string>;
97
90
  type ExtractOptions = {
98
- /**
99
- * The object from where the property/properties will be extracted.
100
- */
91
+ /** The object from where the property/properties will be extracted. */
101
92
  target: unknown;
102
93
  /**
103
94
  * This can be a single path or a list of them. And for this method, the paths are not
@@ -105,9 +96,7 @@ type ExtractOptions = {
105
96
  * where to "do the extraction", and the value the path on the target object.
106
97
  */
107
98
  paths: extractionPath | extractionPath[];
108
- /**
109
- * The delimiter that will separate the path components.
110
- */
99
+ /** The delimiter that will separate the path components. */
111
100
  pathDelimiter?: string;
112
101
  /**
113
102
  * Whether or not to throw an error when the path is invalid. If this is `false`, the
@@ -118,10 +107,7 @@ type ExtractOptions = {
118
107
  /**
119
108
  * Extracts a property or properties from an object in order to create a new one.
120
109
  *
121
- * @param options The options to use.
122
- * @template T The type of the returned object.
123
110
  * @example
124
- *
125
111
  * const target = {
126
112
  * name: {
127
113
  * first: 'Pilar',
@@ -140,20 +126,20 @@ type ExtractOptions = {
140
126
  * );
141
127
  * // Will output { name: 'Pilar', age: 3, address: { planet: 'earth' } }
142
128
  *
129
+ * @template T The type of the returned object.
130
+ * @param options The options to use.
143
131
  */
144
132
  declare const extract: <T = Record<string, unknown>>(options: ExtractOptions) => T | undefined;
145
133
 
146
134
  /**
147
135
  * Checks whether a key for an array or an Object should be flattened.
148
136
  *
149
- * @param key The key to check inside its parent.
150
- * @param value The value of the key.
137
+ * @param key The key to check inside its parent.
138
+ * @param value The value of the key.
151
139
  */
152
140
  type ShouldFlattenFn = (key: string, value: unknown) => boolean;
153
141
  type FlatOptions = {
154
- /**
155
- * The object to transform.
156
- */
142
+ /** The object to transform. */
157
143
  target: unknown;
158
144
  /**
159
145
  * A custom prefix to be added before the name of the properties. This can be used on
@@ -161,9 +147,7 @@ type FlatOptions = {
161
147
  * sub object.
162
148
  */
163
149
  prefix?: string;
164
- /**
165
- * The delimiter that will separate the path components.
166
- */
150
+ /** The delimiter that will separate the path components. */
167
151
  pathDelimiter?: string;
168
152
  /**
169
153
  * A custom function that can be used in order to tell the function whether an Object or
@@ -174,49 +158,38 @@ type FlatOptions = {
174
158
  /**
175
159
  * Flattens an object properties into a single level dictionary.
176
160
  *
177
- * @param options The options to use.
178
- * @template T The type of the returned object.
179
161
  * @example
162
+ * const target = {
163
+ * propOne: {
164
+ * propOneSub: 'Charito!',
165
+ * },
166
+ * propTwo: '!!!',
167
+ * };
168
+ * console.log(flat({ target });
169
+ * // Will output { 'propOne.propOneSub': 'Charito!', propTwo: '!!!' }
180
170
  *
181
- * const target = {
182
- * propOne: {
183
- * propOneSub: 'Charito!',
184
- * },
185
- * propTwo: '!!!',
186
- * };
187
- * console.log(flat({ target });
188
- * // Will output { 'propOne.propOneSub': 'Charito!', propTwo: '!!!' }
189
- *
171
+ * @template T The type of the returned object.
172
+ * @param options The options to use.
190
173
  */
191
174
  declare const flat: <T = Record<string, unknown>>(options: FlatOptions) => T;
192
175
 
193
176
  type GetOptions = {
194
- /**
195
- * The object from where the property will be read.
196
- */
177
+ /** The object from where the property will be read. */
197
178
  target: unknown;
198
- /**
199
- * The path to the property.
200
- */
179
+ /** The path to the property. */
201
180
  path: string;
202
- /**
203
- * The delimiter that will separate the path components.
204
- */
181
+ /** The delimiter that will separate the path components. */
205
182
  pathDelimiter?: string;
206
183
  /**
207
- * Whether or not to throw an error when the path is invalid. If this is `false`,
208
- * the method will silently fail and return `undefined`.
184
+ * Whether or not to throw an error when the path is invalid. If this is `false`, the
185
+ * method will silently fail and return `undefined`.
209
186
  */
210
187
  failWithError?: boolean;
211
188
  };
212
189
  /**
213
190
  * Returns the value of an object property using a path.
214
191
  *
215
- * @param options The options to use.
216
- * @template T The type of the returned object.
217
- * @throws {Error} If the path is invalid and `failWithError` is set to `true`.
218
192
  * @example
219
- *
220
193
  * const obj = {
221
194
  * propOne: {
222
195
  * propOneSub: 'Charito!',
@@ -226,16 +199,19 @@ type GetOptions = {
226
199
  * console.log(get({ target: obj, path: 'propOne.propOneSub' }));
227
200
  * // Will output 'Charito!'
228
201
  *
202
+ * @template T The type of the returned object.
203
+ * @param options The options to use.
204
+ * @throws {Error} If the path is invalid and `failWithError` is set to `true`.
229
205
  */
230
206
  declare function get<T>(options: GetOptions): T | undefined;
231
207
  declare function get<T>(options: unknown, path: string): T | undefined;
232
208
 
233
209
  /**
234
- * A shorthand method for {@link formatKeys} that transforms the keys from
235
- * `lowerCamelCase` to `dash-case`.
210
+ * A shorthand method for {@link formatKeys} that transforms the keys from `lowerCamelCase`
211
+ * to `dash-case`.
236
212
  *
237
- * @param options The options to use.
238
- * @template T The type of the returned object.
213
+ * @template T The type of the returned object.
214
+ * @param options The options to use.
239
215
  */
240
216
  declare const lowerCamelToDashKeys: <T>(options: FormatKeysExtensionOptions) => T;
241
217
 
@@ -243,8 +219,8 @@ declare const lowerCamelToDashKeys: <T>(options: FormatKeysExtensionOptions) =>
243
219
  * A shorthand method for {@link formatKeys} that transforms the keys from
244
220
  * `lowerCamelCase` to `snake_case`.
245
221
  *
246
- * @param options The options to use.
247
- * @template T The type of the returned object.
222
+ * @template T The type of the returned object.
223
+ * @param options The options to use.
248
224
  */
249
225
  declare const lowerCamelToSnakeKeys: <T>(options: FormatKeysExtensionOptions) => T;
250
226
 
@@ -253,37 +229,29 @@ declare const lowerCamelToSnakeKeys: <T>(options: FormatKeysExtensionOptions) =>
253
229
  * supports arrays: if the first element is an array, it will be merged into an array,
254
230
  * otherwise, it will be an object.
255
231
  *
256
- * @param targets The list of objects to merge.
257
- * @template T The type of the merged object that will be returned.
258
232
  * @example
259
- *
260
233
  * const objA = { a: 'first' };
261
234
  * const objB = { b: 'second' };
262
235
  * console.log(merge(objA, objB));
263
236
  * // Will output { a: 'first', b: 'second' }
264
237
  *
265
238
  * @example
266
- *
267
239
  * const arrA = [{ a: 'first' }];
268
240
  * const arrB = [{ b: 'second' }];
269
241
  * console.log(merge(objA, objB));
270
242
  * // Will output [{ a: 'first', b: 'second' }]
271
243
  *
244
+ * @template T The type of the merged object that will be returned.
245
+ * @param targets The list of objects to merge.
272
246
  */
273
247
  declare const merge: <T = unknown>(...targets: unknown[]) => T;
274
248
 
275
249
  type RemoveOptions = {
276
- /**
277
- * The object from where the property will be removed.
278
- */
250
+ /** The object from where the property will be removed. */
279
251
  target: unknown;
280
- /**
281
- * The path to the property.
282
- */
252
+ /** The path to the property. */
283
253
  path: string;
284
- /**
285
- * The delimiter that will separate the path components.
286
- */
254
+ /** The delimiter that will separate the path components. */
287
255
  pathDelimiter?: string;
288
256
  /**
289
257
  * Whether or not to throw an error when the path is invalid. If this is `false`, the
@@ -291,18 +259,15 @@ type RemoveOptions = {
291
259
  */
292
260
  failWithError?: boolean;
293
261
  /**
294
- * If this flag is `true` and after removing the property the parent object is empty,
295
- * it will remove it recursively until a non empty parent object is found.
262
+ * If this flag is `true` and after removing the property the parent object is empty, it
263
+ * will remove it recursively until a non empty parent object is found.
296
264
  */
297
265
  cleanEmptyProperties?: boolean;
298
266
  };
299
267
  /**
300
268
  * Deletes a property of an object using a path.
301
269
  *
302
- * @param options The options to use.
303
- * @template T The type of the returned object.
304
270
  * @example
305
- *
306
271
  * const target = {
307
272
  * propOne: {
308
273
  * propOneSub: 'Charito!',
@@ -312,30 +277,24 @@ type RemoveOptions = {
312
277
  * console.log(remove({ target, path: 'propOne.propOneSub' }));
313
278
  * // Will output { propTwo: '!!!' }
314
279
  *
280
+ * @template T The type of the returned object.
281
+ * @param options The options to use.
315
282
  */
316
283
  declare function remove<T = unknown>(options: RemoveOptions): T | undefined;
317
284
  declare function remove<T = unknown>(options: unknown, path: string): T | undefined;
318
285
 
319
286
  type SetOptions = {
320
- /**
321
- * The object where the property will be set.
322
- */
287
+ /** The object where the property will be set. */
323
288
  target: unknown;
324
- /**
325
- * The path for the property.
326
- */
289
+ /** The path for the property. */
327
290
  path: string;
328
- /**
329
- * The value to set on the property.
330
- */
291
+ /** The value to set on the property. */
331
292
  value: unknown;
332
- /**
333
- * The delimiter that will separate the path components.
334
- */
293
+ /** The delimiter that will separate the path components. */
335
294
  pathDelimiter?: string;
336
295
  /**
337
- * Whether or not to throw an error when the path is invalid. If this is `false`, the method
338
- * will silently fail and return `undefined`.
296
+ * Whether or not to throw an error when the path is invalid. If this is `false`, the
297
+ * method will silently fail and return `undefined`.
339
298
  */
340
299
  failWithError?: boolean;
341
300
  };
@@ -343,16 +302,15 @@ type SetOptions = {
343
302
  * Sets a property on an object using a path. If the path doesn't exist, it will be
344
303
  * created.
345
304
  *
346
- * @param options The options to use.
347
- * @template T The type of the returned object.
348
- * @throws {Error} If one of the path components is for a non-object property and
349
- * `failWithError` is set to `true`.
350
305
  * @example
351
- *
352
306
  * const target = {};
353
307
  * console.log(set({ target, path: 'some.prop.path', value: 'some-value' }));
354
308
  * // Will output { some: { prop: { path: 'some-value' } } }
355
309
  *
310
+ * @template T The type of the returned object.
311
+ * @param options The options to use.
312
+ * @throws {Error} If one of the path components is for a non-object property and
313
+ * `failWithError` is set to `true`.
356
314
  */
357
315
  declare function set<T = Record<string, unknown>>(options: SetOptions): T | undefined;
358
316
  declare function set<T = Record<string, unknown>>(options: SetOptions | unknown, path: string, value: unknown): T | undefined;
@@ -361,8 +319,8 @@ declare function set<T = Record<string, unknown>>(options: SetOptions | unknown,
361
319
  * A shorthand method for {@link formatKeys} that transforms the keys from `snake_case` to
362
320
  * `dash-case`.
363
321
  *
364
- * @param options The options to use.
365
- * @template T The type of the returned object.
322
+ * @template T The type of the returned object.
323
+ * @param options The options to use.
366
324
  */
367
325
  declare const snakeToDashKeys: <T>(options: FormatKeysExtensionOptions) => T;
368
326
 
@@ -370,29 +328,22 @@ declare const snakeToDashKeys: <T>(options: FormatKeysExtensionOptions) => T;
370
328
  * A shorthand method for {@link formatKeys} that transforms the keys from `snake_case` to
371
329
  * `lowerCamelCase`.
372
330
  *
373
- * @param options The options to use.
374
- * @template T The type of the returned object.
331
+ * @template T The type of the returned object.
332
+ * @param options The options to use.
375
333
  */
376
334
  declare const snakeToLowerCamelKeys: <T>(options: FormatKeysExtensionOptions) => T;
377
335
 
378
336
  type UnflatOptions = {
379
- /**
380
- * The object to transform.
381
- */
337
+ /** The object to transform. */
382
338
  target: unknown;
383
- /**
384
- * The delimiter that will separate the path components.
385
- */
339
+ /** The delimiter that will separate the path components. */
386
340
  pathDelimiter?: string;
387
341
  };
388
342
  /**
389
343
  * This method does the exact opposite from `flat`: It takes an already flatten object and
390
344
  * restores it structure.
391
345
  *
392
- * @param options The options to use.
393
- * @template T The type of the returned object.
394
346
  * @example
395
- *
396
347
  * const target = {
397
348
  * 'propOne.propOneSub': 'Charito!',
398
349
  * propTwo: '!!!',
@@ -400,6 +351,8 @@ type UnflatOptions = {
400
351
  * console.log(unflat({ target }));
401
352
  * // Will output { propOne: { propOneSub: 'Charito!' }, 'propTwo': '!!!' }
402
353
  *
354
+ * @template T The type of the returned object.
355
+ * @param options The options to use.
403
356
  */
404
357
  declare const unflat: <T = Record<string, unknown>>(options: UnflatOptions) => T;
405
358
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/fns/merge.ts","../src/fns/copy.ts","../src/fns/formatKeys.ts","../src/fns/dashToLowerCamelKeys.ts","../src/fns/dashToSnakeKeys.ts","../src/fns/get.ts","../src/fns/set.ts","../src/fns/extract.ts","../src/fns/flat.ts","../src/fns/lowerCamelToDashKeys.ts","../src/fns/lowerCamelToSnakeKeys.ts","../src/fns/remove.ts","../src/fns/snakeToDashKeys.ts","../src/fns/snakeToLowerCamelKeys.ts","../src/fns/unflat.ts"],"sourcesContent":["import extend from 'extend';\n\n/**\n * This method makes a deep merge of a list of objects into a new one. The method also\n * supports arrays: if the first element is an array, it will be merged into an array,\n * otherwise, it will be an object.\n *\n * @param targets The list of objects to merge.\n * @template T The type of the merged object that will be returned.\n * @example\n *\n * const objA = { a: 'first' };\n * const objB = { b: 'second' };\n * console.log(merge(objA, objB));\n * // Will output { a: 'first', b: 'second' }\n *\n * @example\n *\n * const arrA = [{ a: 'first' }];\n * const arrB = [{ b: 'second' }];\n * console.log(merge(objA, objB));\n * // Will output [{ a: 'first', b: 'second' }]\n *\n */\nexport const merge = <T = unknown>(...targets: unknown[]): T => {\n const [firstTarget] = targets;\n const base = Array.isArray(firstTarget) ? [] : {};\n return extend(true, base, ...targets) as T;\n};\n","import { merge } from './merge.js';\n\n/**\n * Creates a deep copy of a given object.\n *\n * @param target The object to copy.\n * @template T The type of the input object, which will be the same as the one\n * returned.\n */\nexport const copy = <T>(target: T): T => merge(target);\n","/**\n * The callback that will be used to replace a key.\n *\n * @param substring The captured string to replace.\n * @param args The list of groups captured by the expression.\n */\nexport type FormatKeysReplaceFn = (substring: string, ...args: string[]) => string;\n\nexport type FormatKeysOptions = {\n /**\n * The object to transform.\n */\n target: unknown;\n /**\n * A regular expression to match the keys to transform.\n */\n search: RegExp;\n /**\n * The callback that will be used to replace the matched substring. Think of `search` and\n * `replace` as the parameters of `String.replace`.\n */\n replace: FormatKeysReplaceFn;\n /**\n * A list of keys or paths where the transformation will be made. If not specified, the\n * function will use all the keys from the object.\n */\n include?: string[];\n /**\n * A list of keys or paths where the transformation won't be made.\n */\n exclude?: string[];\n /**\n * The delimiter that will separate the path components for both `include` and `exclude`.\n */\n pathDelimiter?: string;\n};\n\nexport type FormatKeysExtensionOptions = Omit<FormatKeysOptions, 'search' | 'replace'>;\n\n/**\n * Formats all the keys on an object using a way similar to `.replace(regexp, ...)` but\n * that also works recursively and with _\"object paths\"_.\n *\n * @param options The set of options to customize the transformation.\n * @template T The type of the returned object.\n * @example\n *\n * const target = {\n * prop_one: 'Charito!',\n * };\n * console.log(\n * formatKeys({\n * target,\n * // Find all the keys with snake case.\n * search: /([a-z])_([a-z])/g,\n * // Using the same .replace style callback, replace it with lower camel case.\n * replace: (_, firstLetter, secondLetter) => {\n * const newSecondLetter = secondLetter.toUpperCase();\n * return `${firstLetter}${newSecondLetter}`;\n * },\n * }),\n * );\n * // Will output { propOne: 'Charito!}.\n *\n */\nexport const formatKeys = <T = Record<string, unknown>>(\n options: FormatKeysOptions,\n): T => {\n const {\n target,\n search,\n replace,\n include = [],\n exclude = [],\n pathDelimiter = '.',\n } = options;\n // Re-case target.\n const useTarget = target as Record<string, unknown>;\n // First of all, get all the keys from the target.\n const keys = Object.keys(target as Record<string, unknown>);\n /**\n * Then, check which keys are parent to other objects.\n * This is saved on a dictionary not only because it makes it easier to check if the\n * method should make a recursive call for a key, but also because when parsing the\n * `exclude`\n * parameter, if one of items is a key (and not an specific path), the method won't make\n * the recursive call.\n *\n * @ignore\n */\n const hasChildrenByKey: Record<string, unknown> = {};\n keys.forEach((key) => {\n const value = useTarget[key];\n hasChildrenByKey[key] = !!(\n value &&\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n Object.keys(value)\n );\n });\n /**\n * Escape the path delimiter and create two regular expression: One that removes the path\n * delimiter from the start of a path and one that removes it from the end.\n * They are later used to normalize paths in order to avoid \"incomplete paths\" (paths that\n * end or start with the delimiter).\n */\n const escapedPathDelimiter = pathDelimiter.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n const cleanPathStartExpression = new RegExp(`^${escapedPathDelimiter}`, 'i');\n const cleanPathEndExpression = new RegExp(`${escapedPathDelimiter}$`, 'i');\n /**\n * This dictionary will be used to save the `include` parameter that will be sent for specific\n * keys on recursive calls.\n * If `include` has a path like `myKey.mySubKey`, `myKey` is not transformed, but `mySubKey`\n * is saved on this dictionary (`{ myKey: ['mySubKey']}`) and when the method applies the\n * formatting to the object, if `myKey` has an object, it will make a recursive all and\n * send `['mySubKey]` as its `include` parameter.\n */\n const subIncludeByKey: Record<string, string[]> = {};\n /**\n * This will be an array containing the final list of `keys` that should be tranformed.\n * To be clear, these keys will be from the top level, so, they won't be paths.\n * Thd following blocks will parse `include` and `exclude` in order to extract the real keys,\n * prepare the `include` and `exclude` for recursive calls, and save the actual keys\n * from the object \"at the current level of this call\" (no, it's not thinking about the\n * children :P).\n */\n let keysToFormat: string[];\n // If the `include` parameter has paths/keys...\n if (include.length) {\n keysToFormat = include\n .map((includePath) => {\n // Normalize the path/key.\n const useIncludePath = includePath\n .replace(cleanPathStartExpression, '')\n .replace(cleanPathEndExpression, '');\n // Define the variable that will, eventually, have the real key.\n let key;\n // If the value is a path...\n if (useIncludePath.includes(pathDelimiter)) {\n // Split all its components.\n const pathParts = useIncludePath.split(pathDelimiter);\n // Get the first component, a.k.a. the real key.\n const pathKey = pathParts.shift()!;\n /**\n * This is very important: Since the path was specified with sub components\n * (like `myProp.mySubProp`), the method won't format the key, but the sub\n * key(s)\n * (`mySubProp`).\n * The `key` is set to `''` so it will be later removed using `.filter`.\n *\n * @ignore\n */\n key = '';\n /**\n * If there's no array for the key on the \"`include` dictionary for recursive calls\",\n * create an empty one.\n */\n if (!subIncludeByKey[pathKey]) {\n subIncludeByKey[pathKey] = [];\n }\n // Save the rest of the path to be sent on the recursive call as `include`.\n subIncludeByKey[pathKey]!.push(pathParts.join(pathDelimiter));\n } else {\n // If the value wasn't a path, assume it's a key, and set it to be returned.\n key = useIncludePath;\n }\n\n return key;\n })\n // Remove any _empty keys_.\n .filter((key) => key);\n } else {\n // There's nothing on the `include` parameter, so use all the keys.\n keysToFormat = keys;\n }\n /**\n * Similar to `subIncludeByKey`, this dictionary will be used to save the `exclude` parameter\n * that will be sent for specific keys on recursive calls.\n * If `exclude` has a path like `myKey.mySubKey`, `myKey` will be transformed, but `mySubKey`\n * is saved on this dictionary (`{ myKey: ['mySubKey']}`) and when the method applies the\n * formatting to the object, if `myKey` has an object, it will make a recursive all and\n * send `['mySubKey]` as its `exclude` parameter.\n */\n const subExcludeByKey: Record<string, string[]> = {};\n // If the `include` parameter has paths/keys...\n if (exclude.length) {\n /**\n * Create a dictionary of keys that should be removed from `keysToFormat`.\n * It's easier to have them on a list and use `.filter` than actually call `.splice` for\n * every key that should be removed.\n */\n const keysToRemove: string[] = [];\n exclude.forEach((excludePath) => {\n // Normalize the path/key.\n const useExcludePath = excludePath\n .replace(cleanPathStartExpression, '')\n .replace(cleanPathEndExpression, '');\n // If the value is a path...\n if (useExcludePath.includes(pathDelimiter)) {\n // Split all its components.\n const pathParts = useExcludePath.split(pathDelimiter);\n // Get the first component, a.k.a. the real key.\n const pathKey = pathParts.shift()!;\n /**\n * If there's no array for the key on the \"`exclude` dictionary for recursive calls\",\n * create an empty one.\n */\n if (!subExcludeByKey[pathKey]) {\n subExcludeByKey[pathKey] = [];\n }\n // Save the rest of the path to be sent on the recursive call as `exclude`.\n subExcludeByKey[pathKey]!.push(pathParts.join(pathDelimiter));\n } else {\n /**\n * If the value wasn't a path, assume it's a key, turn the flag on the \"children\n * dictionary\" to `false`, to prevent recursive calls, and add the key to the list\n * of keys that will be removed from `keysToFormat`.\n * Basically: If it's a key, don't format it and don't make recursive calls for\n * it.\n *\n * @ignore\n */\n hasChildrenByKey[useExcludePath] = false;\n keysToRemove.push(useExcludePath);\n }\n });\n // Remove keys that should be excluded.\n keysToFormat = keysToFormat.filter((key) => key && !keysToRemove.includes(key));\n }\n // \"Finally\", reduce all the keys from the object and create the new one...\n return keys.reduce<Record<string, unknown>>((newObj, key) => {\n /**\n * Define the new key and value for the object property. Depending on the validations,\n * they may be replaced with formatted ones.\n */\n let newKey;\n let newValue;\n /**\n * Get the current value for the key, in case it's needed for a recursive call or just\n * to send it back because it didn't need any change.\n */\n const value = useTarget[key];\n // If the key should be formatted, apply the formatting; otherwise, keep the original.\n if (keysToFormat.includes(key)) {\n newKey = key.replace(search, replace);\n } else {\n newKey = key;\n }\n /**\n * If the paths/keys on `exclude` didn't modify the \"children dictionary\" for the key and\n * the value is another object, make a recursive call; otherwise, just use the original\n * value.\n */\n if (hasChildrenByKey[key]) {\n newValue = formatKeys({\n target: value,\n search,\n replace,\n include: subIncludeByKey[key] || [],\n exclude: subExcludeByKey[key] || [],\n pathDelimiter,\n });\n } else {\n newValue = value;\n }\n // \"Done\", return the new object with the \"new key\" and the \"new value\".\n return { ...newObj, [newKey]: newValue };\n }, {}) as T;\n};\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from `dash-case`\n * to `lowerCamelCase`.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n */\nexport const dashToLowerCamelKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])-([a-z])/g,\n replace: (_, firstLetter, secondLetter) => {\n const newSecondLetter = secondLetter.toUpperCase();\n return `${firstLetter}${newSecondLetter}`;\n },\n });\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from `dash-case`\n * to `snake_case`.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n */\nexport const dashToSnakeKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])-([a-z])/g,\n replace: (_, firstLetter, secondLetter) => `${firstLetter}_${secondLetter}`,\n });\n","export type GetOptions = {\n /**\n * The object from where the property will be read.\n */\n target: unknown;\n /**\n * The path to the property.\n */\n path: string;\n /**\n * The delimiter that will separate the path components.\n */\n pathDelimiter?: string;\n /**\n * Whether or not to throw an error when the path is invalid. If this is `false`,\n * the method will silently fail and return `undefined`.\n */\n failWithError?: boolean;\n};\n\n/**\n * Returns the value of an object property using a path.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n * @throws {Error} If the path is invalid and `failWithError` is set to `true`.\n * @example\n *\n * const obj = {\n * propOne: {\n * propOneSub: 'Charito!',\n * },\n * propTwo: '!!!',\n * };\n * console.log(get({ target: obj, path: 'propOne.propOneSub' }));\n * // Will output 'Charito!'\n *\n */\nfunction get<T>(options: GetOptions): T | undefined;\nfunction get<T>(options: unknown, path: string): T | undefined;\nfunction get<T>(options: GetOptions | unknown, path?: string): T | undefined {\n let useOptions: GetOptions;\n if (typeof path === 'string') {\n useOptions = {\n target: options,\n path,\n };\n } else {\n useOptions = options as GetOptions;\n }\n\n const {\n target,\n path: usePath,\n pathDelimiter = '.',\n failWithError = false,\n } = useOptions;\n const useTarget = target as Record<string, unknown>;\n const parts = usePath.split(pathDelimiter);\n const first = parts.shift()!;\n let currentElement = useTarget[first] as Record<string, unknown>;\n if (typeof currentElement === 'undefined') {\n if (failWithError) {\n throw new Error(`There's nothing on '${usePath}'`);\n }\n\n return undefined;\n }\n\n if (!parts.length) {\n return currentElement as T;\n }\n\n let currentPath = first;\n parts.some((currentPart) => {\n let breakLoop = false;\n currentPath += `${pathDelimiter}${currentPart}`;\n currentElement = currentElement[currentPart] as Record<string, unknown>;\n if (typeof currentElement === 'undefined') {\n if (failWithError) {\n throw new Error(`There's nothing on '${currentPath}'`);\n } else {\n breakLoop = true;\n }\n }\n\n return breakLoop;\n });\n\n return currentElement as T;\n}\n\nexport { get };\n","import { copy } from './copy.js';\n\n/**\n * List of paths that are forbidden to use on the `set` function, as they could lead to\n * security issues.\n *\n * @access protected\n */\nconst FORBIDDEN_PATHS = ['__proto__', 'prototype', 'constructor'];\n\nexport type SetOptions = {\n /**\n * The object where the property will be set.\n */\n target: unknown;\n /**\n * The path for the property.\n */\n path: string;\n /**\n * The value to set on the property.\n */\n value: unknown;\n /**\n * The delimiter that will separate the path components.\n */\n pathDelimiter?: string;\n /**\n * Whether or not to throw an error when the path is invalid. If this is `false`, the method\n * will silently fail and return `undefined`.\n */\n failWithError?: boolean;\n};\n/**\n * Sets a property on an object using a path. If the path doesn't exist, it will be\n * created.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n * @throws {Error} If one of the path components is for a non-object property and\n * `failWithError` is set to `true`.\n * @example\n *\n * const target = {};\n * console.log(set({ target, path: 'some.prop.path', value: 'some-value' }));\n * // Will output { some: { prop: { path: 'some-value' } } }\n *\n */\nfunction set<T = Record<string, unknown>>(options: SetOptions): T | undefined;\nfunction set<T = Record<string, unknown>>(\n options: SetOptions | unknown,\n path: string,\n value: unknown,\n): T | undefined;\nfunction set<T = Record<string, unknown>>(\n options: SetOptions | unknown,\n path?: string,\n value?: unknown,\n): T | undefined {\n let useOptions: SetOptions;\n if (typeof path === 'string') {\n useOptions = {\n target: options,\n path,\n value,\n };\n } else {\n useOptions = options as SetOptions;\n }\n\n const {\n target,\n path: usePath,\n value: useValue,\n pathDelimiter = '.',\n failWithError = false,\n } = useOptions;\n const result = copy(target) as Record<string, unknown>;\n if (!usePath.includes(pathDelimiter)) {\n if (!usePath || FORBIDDEN_PATHS.includes(usePath.toLowerCase())) {\n return undefined;\n }\n\n result[usePath] = useValue;\n return result as T;\n }\n\n const parts = usePath.split(pathDelimiter);\n const isInvalid = parts.some(\n (part) => !part || FORBIDDEN_PATHS.includes(part.toLowerCase()),\n );\n\n if (isInvalid) {\n return undefined;\n }\n\n // Path validation ensures that every component is defined and non-empty.\n const last = parts.pop()!;\n let currentElement = result;\n let currentPath = '';\n let foundInvalid = false;\n parts.forEach((part) => {\n currentPath += `${pathDelimiter}${part}`;\n const element = currentElement[part];\n const elementType = typeof element;\n if (elementType === 'undefined') {\n currentElement[part] = {};\n currentElement = currentElement[part] as Record<string, unknown>;\n } else if (elementType === 'object') {\n currentElement = currentElement[part] as Record<string, unknown>;\n } else {\n const errorPath = currentPath.substring(pathDelimiter.length);\n if (failWithError) {\n throw new Error(\n `There's already an element of type '${elementType}' on '${errorPath}'`,\n );\n } else {\n foundInvalid = true;\n }\n }\n });\n\n if (foundInvalid) return undefined;\n\n currentElement[last] = useValue;\n\n return result as T | undefined;\n}\n\nexport { set };\n","import { get } from './get.js';\nimport { set } from './set.js';\nimport { copy } from './copy.js';\n/**\n * Used in the {@link extract} function to specify a path for a property, or an \"origin path\"\n * and an \"extraction path\".\n */\nexport type extractionPath = string | Record<string, string>;\n\nexport type ExtractOptions = {\n /**\n * The object from where the property/properties will be extracted.\n */\n target: unknown;\n /**\n * This can be a single path or a list of them. And for this method, the paths are not\n * only strings but can also be an object with a single key, that would be the path to\n * where to \"do the extraction\", and the value the path on the target object.\n */\n paths: extractionPath | extractionPath[];\n /**\n * The delimiter that will separate the path components.\n */\n pathDelimiter?: string;\n /**\n * Whether or not to throw an error when the path is invalid. If this is `false`, the\n * method will silently fail an empty object.\n */\n failWithError?: boolean;\n};\n/**\n * Extracts a property or properties from an object in order to create a new one.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n * @example\n *\n * const target = {\n * name: {\n * first: 'Pilar',\n * },\n * age: 3,\n * address: {\n * planet: 'earth',\n * something: 'else',\n * },\n * };\n * console.log(\n * extract({\n * target: obj,\n * paths: [{ name: 'name.first' }, 'age', 'address.planet'],\n * }),\n * );\n * // Will output { name: 'Pilar', age: 3, address: { planet: 'earth' } }\n *\n */\nexport const extract = <T = Record<string, unknown>>(\n options: ExtractOptions,\n): T | undefined => {\n const { target, paths, pathDelimiter = '.', failWithError = false } = options;\n const copied = copy(target) as Record<string, unknown>;\n let result: Record<string, unknown> = {};\n let failed = false;\n (Array.isArray(paths) ? paths : [paths])\n .reduce<Array<{ origin: string; customDest: boolean; dest: string }>>(\n (acc, objPath) => {\n let destPath: string;\n let originPath: string;\n if (typeof objPath === 'string') {\n destPath = objPath;\n originPath = objPath;\n } else {\n const [firstKey] = Object.keys(objPath);\n destPath = firstKey!;\n originPath = objPath[destPath]!;\n }\n\n acc.push({\n origin: originPath,\n customDest: destPath.includes(pathDelimiter),\n dest: destPath,\n });\n return acc;\n },\n [],\n )\n .some((pathInfo) => {\n let breakLoop = false;\n const value = get({\n target: copied,\n path: pathInfo.origin,\n pathDelimiter,\n failWithError,\n });\n if (typeof value !== 'undefined') {\n if (pathInfo.customDest) {\n const withCustomProp = set({\n target: result,\n path: pathInfo.dest,\n value,\n pathDelimiter,\n failWithError,\n });\n if (typeof withCustomProp === 'undefined') {\n breakLoop = true;\n failed = true;\n } else {\n result = withCustomProp;\n }\n } else {\n result[pathInfo.dest] = value;\n }\n }\n\n return breakLoop;\n });\n\n if (failed) return undefined;\n return result as T;\n};\n","import { copy } from './copy.js';\nimport { merge } from './merge.js';\n\n/**\n * Checks whether a key for an array or an Object should be flattened.\n *\n * @param key The key to check inside its parent.\n * @param value The value of the key.\n */\nexport type ShouldFlattenFn = (key: string, value: unknown) => boolean;\n\nexport type FlatOptions = {\n /**\n * The object to transform.\n */\n target: unknown;\n /**\n * A custom prefix to be added before the name of the properties. This can be used on\n * custom cases and it's also used when the method calls itself in order to flatten a\n * sub object.\n */\n prefix?: string;\n /**\n * The delimiter that will separate the path components.\n */\n pathDelimiter?: string;\n /**\n * A custom function that can be used in order to tell the function whether an Object or\n * an Array property should be flatten or not.\n */\n shouldFlatten?: ShouldFlattenFn;\n};\n/**\n * Flattens an object properties into a single level dictionary.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n * @example\n *\n * const target = {\n * propOne: {\n * propOneSub: 'Charito!',\n * },\n * propTwo: '!!!',\n * };\n * console.log(flat({ target });\n * // Will output { 'propOne.propOneSub': 'Charito!', propTwo: '!!!' }\n *\n */\nexport const flat = <T = Record<string, unknown>>(options: FlatOptions): T => {\n const { target, shouldFlatten, pathDelimiter = '.', prefix = '' } = options;\n const useTarget = target as Record<string, unknown>;\n let result: Record<string, unknown> = {};\n const namePrefix = prefix ? `${prefix}${pathDelimiter}` : '';\n Object.keys(useTarget).forEach((key) => {\n const name = `${namePrefix}${key}`;\n const value = useTarget[key] as unknown;\n const valueType = typeof value;\n const isObject = valueType === 'object' && value !== null;\n if (isObject && (!shouldFlatten || shouldFlatten(key, value))) {\n result = merge(\n result,\n flat({ target: value, pathDelimiter, prefix: name, shouldFlatten }),\n );\n } else {\n result[name] = isObject ? copy(value) : value;\n }\n });\n\n return result as T;\n};\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from\n * `lowerCamelCase` to `dash-case`.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n */\nexport const lowerCamelToDashKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])([A-Z])/g,\n replace: (_, firstLetter, secondLetter) => {\n const newSecondLetter = secondLetter.toLowerCase();\n return `${firstLetter}-${newSecondLetter}`;\n },\n });\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from\n * `lowerCamelCase` to `snake_case`.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n */\nexport const lowerCamelToSnakeKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])([A-Z])/g,\n replace: (_, firstLetter, secondLetter) => {\n const newSecondLetter = secondLetter.toLowerCase();\n return `${firstLetter}_${newSecondLetter}`;\n },\n });\n","import { copy } from './copy.js';\nimport { get } from './get.js';\n\nexport type RemoveOptions = {\n /**\n * The object from where the property will be removed.\n */\n target: unknown;\n /**\n * The path to the property.\n */\n path: string;\n /**\n * The delimiter that will separate the path components.\n */\n pathDelimiter?: string;\n /**\n * Whether or not to throw an error when the path is invalid. If this is `false`, the\n * function will silently fail.\n */\n failWithError?: boolean;\n /**\n * If this flag is `true` and after removing the property the parent object is empty,\n * it will remove it recursively until a non empty parent object is found.\n */\n cleanEmptyProperties?: boolean;\n};\n/**\n * Deletes a property of an object using a path.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n * @example\n *\n * const target = {\n * propOne: {\n * propOneSub: 'Charito!',\n * },\n * propTwo: '!!!',\n * };\n * console.log(remove({ target, path: 'propOne.propOneSub' }));\n * // Will output { propTwo: '!!!' }\n *\n */\nfunction remove<T = unknown>(options: RemoveOptions): T | undefined;\nfunction remove<T = unknown>(options: unknown, path: string): T | undefined;\nfunction remove<T = unknown>(\n options: RemoveOptions | unknown,\n path?: string,\n): T | undefined {\n let useOptions: RemoveOptions;\n if (typeof path === 'string') {\n useOptions = {\n target: options,\n path,\n };\n } else {\n useOptions = options as RemoveOptions;\n }\n\n const {\n target,\n path: usePath,\n pathDelimiter = '.',\n cleanEmptyProperties = true,\n failWithError = false,\n } = useOptions;\n\n const parts = usePath.split(pathDelimiter);\n const last = parts.pop()!;\n const result = copy(target) as Record<string, unknown>;\n if (!parts.length) {\n delete result[last];\n return result as T;\n }\n const parentPath = parts.join(pathDelimiter);\n const parentObj = get<Record<string, unknown>>({\n target: result,\n path: parentPath,\n pathDelimiter,\n failWithError,\n });\n\n if (typeof parentObj === 'undefined') {\n return undefined;\n }\n\n delete parentObj[last];\n if (cleanEmptyProperties && !Object.keys(parentObj).length) {\n return remove({\n target: result,\n path: parentPath,\n pathDelimiter,\n failWithError,\n cleanEmptyProperties,\n }) as T;\n }\n\n return result as T;\n}\n\nexport { remove };\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from `snake_case` to\n * `dash-case`.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n */\nexport const snakeToDashKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])_([a-z])/g,\n replace: (_, firstLetter, secondLetter) => `${firstLetter}-${secondLetter}`,\n });\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from `snake_case` to\n * `lowerCamelCase`.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n */\nexport const snakeToLowerCamelKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])_([a-z])/g,\n replace: (_, firstLetter, secondLetter) => {\n const newSecondLetter = secondLetter.toUpperCase();\n return `${firstLetter}${newSecondLetter}`;\n },\n });\n","import { set } from './set.js';\n\nexport type UnflatOptions = {\n /**\n * The object to transform.\n */\n target: unknown;\n /**\n * The delimiter that will separate the path components.\n */\n pathDelimiter?: string;\n};\n/**\n * This method does the exact opposite from `flat`: It takes an already flatten object and\n * restores it structure.\n *\n * @param options The options to use.\n * @template T The type of the returned object.\n * @example\n *\n * const target = {\n * 'propOne.propOneSub': 'Charito!',\n * propTwo: '!!!',\n * };\n * console.log(unflat({ target }));\n * // Will output { propOne: { propOneSub: 'Charito!' }, 'propTwo': '!!!' }\n *\n */\nexport const unflat = <T = Record<string, unknown>>(options: UnflatOptions): T => {\n const { target, pathDelimiter = '.' } = options;\n const useTarget = target as Record<string, unknown>;\n return Object.keys(useTarget).reduce<Record<string, unknown>>(\n (current, key) =>\n set({ target: current, path: key, value: useTarget[key], pathDelimiter })!,\n {},\n ) as T;\n};\n"],"mappings":"AAAA,OAAOA,MAAY,SAwBZ,IAAMC,EAAQ,IAAiBC,IAA0B,CAC9D,GAAM,CAACC,CAAW,EAAID,EAChBE,EAAO,MAAM,QAAQD,CAAW,EAAI,CAAC,EAAI,CAAC,EAChD,OAAOH,EAAO,GAAMI,EAAM,GAAGF,CAAO,CACtC,ECnBO,IAAMG,EAAWC,GAAiBC,EAAMD,CAAM,ECwD9C,IAAME,EACXC,GACM,CACN,GAAM,CACJ,OAAAC,EACA,OAAAC,EACA,QAAAC,EACA,QAAAC,EAAU,CAAC,EACX,QAAAC,EAAU,CAAC,EACX,cAAAC,EAAgB,GAClB,EAAIN,EAEEO,EAAYN,EAEZO,EAAO,OAAO,KAAKP,CAAiC,EAWpDQ,EAA4C,CAAC,EACnDD,EAAK,QAASE,GAAQ,CACpB,IAAMC,EAAQJ,EAAUG,CAAG,EAC3BD,EAAiBC,CAAG,EAAI,CAAC,EACvBC,GACA,OAAOA,GAAU,UACjBA,IAAU,MACV,CAAC,MAAM,QAAQA,CAAK,GACpB,OAAO,KAAKA,CAAK,EAErB,CAAC,EAOD,IAAMC,EAAuB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ASC,EAAKR,CAAM,EAC1B,GAAI,CAACK,EAAM,OACT,cAAOE,EAAOD,CAAI,EACXC,EAET,IAAME,EAAaJ,EAAM,KAAKH,CAAa,EACrCQ,EAAYC,EAA6B,CAC7C,OAAQJ,EACR,KAAME,EACN,cAAAP,EACA,cAAAE,CACF,CAAC,EAED,GAAI,SAAOM,EAAc,KAKzB,OADA,OAAOA,EAAUJ,CAAI,EACjBH,GAAwB,CAAC,OAAO,KAAKO,CAAS,EAAE,OAC3Cd,EAAO,CACZ,OAAQW,EACR,KAAME,EACN,cAAAP,EACA,cAAAE,EACA,qBAAAD,CACF,CAAC,EAGII,CACT,CC1FO,IAAMK,GAAsBC,GACjCC,EAAc,CACZ,GAAGD,EACH,OAAQ,mBACR,QAAS,CAACE,EAAGC,EAAaC,IAAiB,GAAGD,CAAW,IAAIC,CAAY,EAC3E,CAAC,ECLI,IAAMC,GAA4BC,GACvCC,EAAc,CACZ,GAAGD,EACH,OAAQ,mBACR,QAAS,CAACE,EAAGC,EAAaC,IAAiB,CACzC,IAAMC,EAAkBD,EAAa,YAAY,EACjD,MAAO,GAAGD,CAAW,GAAGE,CAAe,EACzC,CACF,CAAC,ECWI,IAAMC,GAAuCC,GAA8B,CAChF,GAAM,CAAE,OAAAC,EAAQ,cAAAC,EAAgB,GAAI,EAAIF,EAClCG,EAAYF,EAClB,OAAO,OAAO,KAAKE,CAAS,EAAE,OAC5B,CAACC,EAASC,IACRC,EAAI,CAAE,OAAQF,EAAS,KAAMC,EAAK,MAAOF,EAAUE,CAAG,EAAG,cAAAH,CAAc,CAAC,EAC1E,CAAC,CACH,CACF","names":["extend","merge","targets","firstTarget","base","copy","target","merge","formatKeys","options","target","search","replace","include","exclude","pathDelimiter","useTarget","keys","hasChildrenByKey","key","value","escapedPathDelimiter","cleanPathStartExpression","cleanPathEndExpression","subIncludeByKey","keysToFormat","includePath","useIncludePath","pathParts","pathKey","subExcludeByKey","keysToRemove","excludePath","useExcludePath","newObj","newKey","newValue","dashToLowerCamelKeys","options","formatKeys","_","firstLetter","secondLetter","newSecondLetter","dashToSnakeKeys","options","formatKeys","_","firstLetter","secondLetter","get","options","path","useOptions","target","usePath","pathDelimiter","failWithError","useTarget","parts","first","currentElement","currentPath","currentPart","breakLoop","FORBIDDEN_PATHS","set","options","path","value","useOptions","target","usePath","useValue","pathDelimiter","failWithError","result","copy","parts","part","last","currentElement","currentPath","foundInvalid","elementType","errorPath","extract","options","target","paths","pathDelimiter","failWithError","copied","copy","result","failed","acc","objPath","destPath","originPath","firstKey","pathInfo","breakLoop","value","get","withCustomProp","set","flat","options","target","shouldFlatten","pathDelimiter","prefix","useTarget","result","namePrefix","key","name","value","isObject","merge","copy","lowerCamelToDashKeys","options","formatKeys","_","firstLetter","secondLetter","newSecondLetter","lowerCamelToSnakeKeys","options","formatKeys","_","firstLetter","secondLetter","newSecondLetter","remove","options","path","useOptions","target","usePath","pathDelimiter","cleanEmptyProperties","failWithError","parts","last","result","copy","parentPath","parentObj","get","snakeToDashKeys","options","formatKeys","_","firstLetter","secondLetter","snakeToLowerCamelKeys","options","formatKeys","_","firstLetter","secondLetter","newSecondLetter","unflat","options","target","pathDelimiter","useTarget","current","key","set"]}
1
+ {"version":3,"sources":["../src/fns/merge.ts","../src/fns/copy.ts","../src/fns/formatKeys.ts","../src/fns/dashToLowerCamelKeys.ts","../src/fns/dashToSnakeKeys.ts","../src/fns/get.ts","../src/fns/set.ts","../src/fns/extract.ts","../src/fns/flat.ts","../src/fns/lowerCamelToDashKeys.ts","../src/fns/lowerCamelToSnakeKeys.ts","../src/fns/remove.ts","../src/fns/snakeToDashKeys.ts","../src/fns/snakeToLowerCamelKeys.ts","../src/fns/unflat.ts"],"sourcesContent":["import extend from 'extend';\n\n/**\n * This method makes a deep merge of a list of objects into a new one. The method also\n * supports arrays: if the first element is an array, it will be merged into an array,\n * otherwise, it will be an object.\n *\n * @example\n * const objA = { a: 'first' };\n * const objB = { b: 'second' };\n * console.log(merge(objA, objB));\n * // Will output { a: 'first', b: 'second' }\n *\n * @example\n * const arrA = [{ a: 'first' }];\n * const arrB = [{ b: 'second' }];\n * console.log(merge(objA, objB));\n * // Will output [{ a: 'first', b: 'second' }]\n *\n * @template T The type of the merged object that will be returned.\n * @param targets The list of objects to merge.\n */\nexport const merge = <T = unknown>(...targets: unknown[]): T => {\n const [firstTarget] = targets;\n const base = Array.isArray(firstTarget) ? [] : {};\n return extend(true, base, ...targets) as T;\n};\n","import { merge } from './merge.js';\n\n/**\n * Creates a deep copy of a given object.\n *\n * @template T The type of the input object, which will be the same as the one returned.\n * @param target The object to copy.\n */\nexport const copy = <T>(target: T): T => merge(target);\n","/**\n * The callback that will be used to replace a key.\n *\n * @param substring The captured string to replace.\n * @param args The list of groups captured by the expression.\n */\nexport type FormatKeysReplaceFn = (substring: string, ...args: string[]) => string;\n\nexport type FormatKeysOptions = {\n /** The object to transform. */\n target: unknown;\n /** A regular expression to match the keys to transform. */\n search: RegExp;\n /**\n * The callback that will be used to replace the matched substring. Think of `search`\n * and `replace` as the parameters of `String.replace`.\n */\n replace: FormatKeysReplaceFn;\n /**\n * A list of keys or paths where the transformation will be made. If not specified, the\n * function will use all the keys from the object.\n */\n include?: string[];\n /** A list of keys or paths where the transformation won't be made. */\n exclude?: string[];\n /**\n * The delimiter that will separate the path components for both `include` and\n * `exclude`.\n */\n pathDelimiter?: string;\n};\n\nexport type FormatKeysExtensionOptions = Omit<FormatKeysOptions, 'search' | 'replace'>;\n\n/**\n * Formats all the keys on an object using a way similar to `.replace(regexp, ...)` but\n * that also works recursively and with _\"object paths\"_.\n *\n * @example\n * const target = {\n * prop_one: 'Charito!',\n * };\n * console.log(\n * formatKeys({\n * target,\n * // Find all the keys with snake case.\n * search: /([a-z])_([a-z])/g,\n * // Using the same .replace style callback, replace it with lower camel case.\n * replace: (_, firstLetter, secondLetter) => {\n * const newSecondLetter = secondLetter.toUpperCase();\n * return `${firstLetter}${newSecondLetter}`;\n * },\n * }),\n * );\n * // Will output { propOne: 'Charito!}.\n *\n * @template T The type of the returned object.\n * @param options The set of options to customize the transformation.\n */\nexport const formatKeys = <T = Record<string, unknown>>(\n options: FormatKeysOptions,\n): T => {\n const {\n target,\n search,\n replace,\n include = [],\n exclude = [],\n pathDelimiter = '.',\n } = options;\n // Re-case target.\n const useTarget = target as Record<string, unknown>;\n // First of all, get all the keys from the target.\n const keys = Object.keys(target as Record<string, unknown>);\n /**\n * Then, check which keys are parent to other objects. This is saved on a dictionary not\n * only because it makes it easier to check if the method should make a recursive call\n * for a key, but also because when parsing the `exclude` parameter, if one of items is\n * a key (and not an specific path), the method won't make the recursive call.\n *\n * @ignore\n */\n const hasChildrenByKey: Record<string, unknown> = {};\n keys.forEach((key) => {\n const value = useTarget[key];\n hasChildrenByKey[key] = !!(\n value &&\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n Object.keys(value)\n );\n });\n /**\n * Escape the path delimiter and create two regular expression: One that removes the\n * path delimiter from the start of a path and one that removes it from the end. They\n * are later used to normalize paths in order to avoid \"incomplete paths\" (paths that\n * end or start with the delimiter).\n */\n const escapedPathDelimiter = pathDelimiter.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n const cleanPathStartExpression = new RegExp(`^${escapedPathDelimiter}`, 'i');\n const cleanPathEndExpression = new RegExp(`${escapedPathDelimiter}$`, 'i');\n /**\n * This dictionary will be used to save the `include` parameter that will be sent for\n * specific keys on recursive calls. If `include` has a path like `myKey.mySubKey`,\n * `myKey` is not transformed, but `mySubKey` is saved on this dictionary (`{ myKey:\n * ['mySubKey']}`) and when the method applies the formatting to the object, if `myKey`\n * has an object, it will make a recursive all and send `['mySubKey]` as its `include`\n * parameter.\n */\n const subIncludeByKey: Record<string, string[]> = {};\n /**\n * This will be an array containing the final list of `keys` that should be tranformed.\n * To be clear, these keys will be from the top level, so, they won't be paths. Thd\n * following blocks will parse `include` and `exclude` in order to extract the real\n * keys, prepare the `include` and `exclude` for recursive calls, and save the actual\n * keys from the object \"at the current level of this call\" (no, it's not thinking about\n * the children :P).\n */\n let keysToFormat: string[];\n // If the `include` parameter has paths/keys...\n if (include.length) {\n keysToFormat = include\n .map((includePath) => {\n // Normalize the path/key.\n const useIncludePath = includePath\n .replace(cleanPathStartExpression, '')\n .replace(cleanPathEndExpression, '');\n // Define the variable that will, eventually, have the real key.\n let key;\n // If the value is a path...\n if (useIncludePath.includes(pathDelimiter)) {\n // Split all its components.\n const pathParts = useIncludePath.split(pathDelimiter);\n // Get the first component, a.k.a. the real key.\n const pathKey = pathParts.shift()!;\n /**\n * This is very important: Since the path was specified with sub components\n * (like `myProp.mySubProp`), the method won't format the key, but the sub\n * key(s) (`mySubProp`). The `key` is set to `''` so it will be later removed\n * using `.filter`.\n *\n * @ignore\n */\n key = '';\n /**\n * If there's no array for the key on the \"`include` dictionary for recursive\n * calls\", create an empty one.\n */\n if (!subIncludeByKey[pathKey]) {\n subIncludeByKey[pathKey] = [];\n }\n // Save the rest of the path to be sent on the recursive call as `include`.\n subIncludeByKey[pathKey]!.push(pathParts.join(pathDelimiter));\n } else {\n // If the value wasn't a path, assume it's a key, and set it to be returned.\n key = useIncludePath;\n }\n\n return key;\n })\n // Remove any _empty keys_.\n .filter((key) => key);\n } else {\n // There's nothing on the `include` parameter, so use all the keys.\n keysToFormat = keys;\n }\n /**\n * Similar to `subIncludeByKey`, this dictionary will be used to save the `exclude`\n * parameter that will be sent for specific keys on recursive calls. If `exclude` has a\n * path like `myKey.mySubKey`, `myKey` will be transformed, but `mySubKey` is saved on\n * this dictionary (`{ myKey: ['mySubKey']}`) and when the method applies the formatting\n * to the object, if `myKey` has an object, it will make a recursive all and send\n * `['mySubKey]` as its `exclude` parameter.\n */\n const subExcludeByKey: Record<string, string[]> = {};\n // If the `include` parameter has paths/keys...\n if (exclude.length) {\n /**\n * Create a dictionary of keys that should be removed from `keysToFormat`. It's easier\n * to have them on a list and use `.filter` than actually call `.splice` for every key\n * that should be removed.\n */\n const keysToRemove: string[] = [];\n exclude.forEach((excludePath) => {\n // Normalize the path/key.\n const useExcludePath = excludePath\n .replace(cleanPathStartExpression, '')\n .replace(cleanPathEndExpression, '');\n // If the value is a path...\n if (useExcludePath.includes(pathDelimiter)) {\n // Split all its components.\n const pathParts = useExcludePath.split(pathDelimiter);\n // Get the first component, a.k.a. the real key.\n const pathKey = pathParts.shift()!;\n /**\n * If there's no array for the key on the \"`exclude` dictionary for recursive\n * calls\", create an empty one.\n */\n if (!subExcludeByKey[pathKey]) {\n subExcludeByKey[pathKey] = [];\n }\n // Save the rest of the path to be sent on the recursive call as `exclude`.\n subExcludeByKey[pathKey]!.push(pathParts.join(pathDelimiter));\n } else {\n /**\n * If the value wasn't a path, assume it's a key, turn the flag on the \"children\n * dictionary\" to `false`, to prevent recursive calls, and add the key to the list\n * of keys that will be removed from `keysToFormat`. Basically: If it's a key,\n * don't format it and don't make recursive calls for it.\n *\n * @ignore\n */\n hasChildrenByKey[useExcludePath] = false;\n keysToRemove.push(useExcludePath);\n }\n });\n // Remove keys that should be excluded.\n keysToFormat = keysToFormat.filter((key) => key && !keysToRemove.includes(key));\n }\n // \"Finally\", reduce all the keys from the object and create the new one...\n return keys.reduce<Record<string, unknown>>((newObj, key) => {\n /**\n * Define the new key and value for the object property. Depending on the validations,\n * they may be replaced with formatted ones.\n */\n let newKey;\n let newValue;\n /**\n * Get the current value for the key, in case it's needed for a recursive call or just\n * to send it back because it didn't need any change.\n */\n const value = useTarget[key];\n // If the key should be formatted, apply the formatting; otherwise, keep the original.\n if (keysToFormat.includes(key)) {\n newKey = key.replace(search, replace);\n } else {\n newKey = key;\n }\n /**\n * If the paths/keys on `exclude` didn't modify the \"children dictionary\" for the key\n * and the value is another object, make a recursive call; otherwise, just use the\n * original value.\n */\n if (hasChildrenByKey[key]) {\n newValue = formatKeys({\n target: value,\n search,\n replace,\n include: subIncludeByKey[key] || [],\n exclude: subExcludeByKey[key] || [],\n pathDelimiter,\n });\n } else {\n newValue = value;\n }\n // \"Done\", return the new object with the \"new key\" and the \"new value\".\n return { ...newObj, [newKey]: newValue };\n }, {}) as T;\n};\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from `dash-case` to\n * `lowerCamelCase`.\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nexport const dashToLowerCamelKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])-([a-z])/g,\n replace: (_, firstLetter, secondLetter) => {\n const newSecondLetter = secondLetter.toUpperCase();\n return `${firstLetter}${newSecondLetter}`;\n },\n });\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from `dash-case` to\n * `snake_case`.\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nexport const dashToSnakeKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])-([a-z])/g,\n replace: (_, firstLetter, secondLetter) => `${firstLetter}_${secondLetter}`,\n });\n","export type GetOptions = {\n /** The object from where the property will be read. */\n target: unknown;\n /** The path to the property. */\n path: string;\n /** The delimiter that will separate the path components. */\n pathDelimiter?: string;\n /**\n * Whether or not to throw an error when the path is invalid. If this is `false`, the\n * method will silently fail and return `undefined`.\n */\n failWithError?: boolean;\n};\n\n/**\n * Returns the value of an object property using a path.\n *\n * @example\n * const obj = {\n * propOne: {\n * propOneSub: 'Charito!',\n * },\n * propTwo: '!!!',\n * };\n * console.log(get({ target: obj, path: 'propOne.propOneSub' }));\n * // Will output 'Charito!'\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n * @throws {Error} If the path is invalid and `failWithError` is set to `true`.\n */\nfunction get<T>(options: GetOptions): T | undefined;\nfunction get<T>(options: unknown, path: string): T | undefined;\nfunction get<T>(options: GetOptions | unknown, path?: string): T | undefined {\n let useOptions: GetOptions;\n if (typeof path === 'string') {\n useOptions = {\n target: options,\n path,\n };\n } else {\n useOptions = options as GetOptions;\n }\n\n const {\n target,\n path: usePath,\n pathDelimiter = '.',\n failWithError = false,\n } = useOptions;\n const useTarget = target as Record<string, unknown>;\n const parts = usePath.split(pathDelimiter);\n const first = parts.shift()!;\n let currentElement = useTarget[first] as Record<string, unknown>;\n if (typeof currentElement === 'undefined') {\n if (failWithError) {\n throw new Error(`There's nothing on '${usePath}'`);\n }\n\n return undefined;\n }\n\n if (!parts.length) {\n return currentElement as T;\n }\n\n let currentPath = first;\n parts.some((currentPart) => {\n let breakLoop = false;\n currentPath += `${pathDelimiter}${currentPart}`;\n currentElement = currentElement[currentPart] as Record<string, unknown>;\n if (typeof currentElement === 'undefined') {\n if (failWithError) {\n throw new Error(`There's nothing on '${currentPath}'`);\n } else {\n breakLoop = true;\n }\n }\n\n return breakLoop;\n });\n\n return currentElement as T;\n}\n\nexport { get };\n","import { copy } from './copy.js';\n\n/**\n * List of paths that are forbidden to use on the `set` function, as they could lead to\n * security issues.\n *\n * @access protected\n */\nconst FORBIDDEN_PATHS = ['__proto__', 'prototype', 'constructor'];\n\nexport type SetOptions = {\n /** The object where the property will be set. */\n target: unknown;\n /** The path for the property. */\n path: string;\n /** The value to set on the property. */\n value: unknown;\n /** The delimiter that will separate the path components. */\n pathDelimiter?: string;\n /**\n * Whether or not to throw an error when the path is invalid. If this is `false`, the\n * method will silently fail and return `undefined`.\n */\n failWithError?: boolean;\n};\n/**\n * Sets a property on an object using a path. If the path doesn't exist, it will be\n * created.\n *\n * @example\n * const target = {};\n * console.log(set({ target, path: 'some.prop.path', value: 'some-value' }));\n * // Will output { some: { prop: { path: 'some-value' } } }\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n * @throws {Error} If one of the path components is for a non-object property and\n * `failWithError` is set to `true`.\n */\nfunction set<T = Record<string, unknown>>(options: SetOptions): T | undefined;\nfunction set<T = Record<string, unknown>>(\n options: SetOptions | unknown,\n path: string,\n value: unknown,\n): T | undefined;\nfunction set<T = Record<string, unknown>>(\n options: SetOptions | unknown,\n path?: string,\n value?: unknown,\n): T | undefined {\n let useOptions: SetOptions;\n if (typeof path === 'string') {\n useOptions = {\n target: options,\n path,\n value,\n };\n } else {\n useOptions = options as SetOptions;\n }\n\n const {\n target,\n path: usePath,\n value: useValue,\n pathDelimiter = '.',\n failWithError = false,\n } = useOptions;\n const result = copy(target) as Record<string, unknown>;\n if (!usePath.includes(pathDelimiter)) {\n if (!usePath || FORBIDDEN_PATHS.includes(usePath.toLowerCase())) {\n return undefined;\n }\n\n result[usePath] = useValue;\n return result as T;\n }\n\n const parts = usePath.split(pathDelimiter);\n const isInvalid = parts.some(\n (part) => !part || FORBIDDEN_PATHS.includes(part.toLowerCase()),\n );\n\n if (isInvalid) {\n return undefined;\n }\n\n // Path validation ensures that every component is defined and non-empty.\n const last = parts.pop()!;\n let currentElement = result;\n let currentPath = '';\n let foundInvalid = false;\n parts.forEach((part) => {\n currentPath += `${pathDelimiter}${part}`;\n const element = currentElement[part];\n const elementType = typeof element;\n if (elementType === 'undefined') {\n currentElement[part] = {};\n currentElement = currentElement[part] as Record<string, unknown>;\n } else if (elementType === 'object') {\n currentElement = currentElement[part] as Record<string, unknown>;\n } else {\n const errorPath = currentPath.substring(pathDelimiter.length);\n if (failWithError) {\n throw new Error(\n `There's already an element of type '${elementType}' on '${errorPath}'`,\n );\n } else {\n foundInvalid = true;\n }\n }\n });\n\n if (foundInvalid) return undefined;\n\n currentElement[last] = useValue;\n\n return result as T | undefined;\n}\n\nexport { set };\n","import { copy } from './copy.js';\nimport { get } from './get.js';\nimport { set } from './set.js';\n/**\n * Used in the {@link extract} function to specify a path for a property, or an \"origin\n * path\" and an \"extraction path\".\n */\nexport type extractionPath = string | Record<string, string>;\n\nexport type ExtractOptions = {\n /** The object from where the property/properties will be extracted. */\n target: unknown;\n /**\n * This can be a single path or a list of them. And for this method, the paths are not\n * only strings but can also be an object with a single key, that would be the path to\n * where to \"do the extraction\", and the value the path on the target object.\n */\n paths: extractionPath | extractionPath[];\n /** The delimiter that will separate the path components. */\n pathDelimiter?: string;\n /**\n * Whether or not to throw an error when the path is invalid. If this is `false`, the\n * method will silently fail an empty object.\n */\n failWithError?: boolean;\n};\n/**\n * Extracts a property or properties from an object in order to create a new one.\n *\n * @example\n * const target = {\n * name: {\n * first: 'Pilar',\n * },\n * age: 3,\n * address: {\n * planet: 'earth',\n * something: 'else',\n * },\n * };\n * console.log(\n * extract({\n * target: obj,\n * paths: [{ name: 'name.first' }, 'age', 'address.planet'],\n * }),\n * );\n * // Will output { name: 'Pilar', age: 3, address: { planet: 'earth' } }\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nexport const extract = <T = Record<string, unknown>>(\n options: ExtractOptions,\n): T | undefined => {\n const { target, paths, pathDelimiter = '.', failWithError = false } = options;\n const copied = copy(target) as Record<string, unknown>;\n let result: Record<string, unknown> = {};\n let failed = false;\n (Array.isArray(paths) ? paths : [paths])\n .reduce<Array<{ origin: string; customDest: boolean; dest: string }>>(\n (acc, objPath) => {\n let destPath: string;\n let originPath: string;\n if (typeof objPath === 'string') {\n destPath = objPath;\n originPath = objPath;\n } else {\n const [firstKey] = Object.keys(objPath);\n destPath = firstKey!;\n originPath = objPath[destPath]!;\n }\n\n acc.push({\n origin: originPath,\n customDest: destPath.includes(pathDelimiter),\n dest: destPath,\n });\n return acc;\n },\n [],\n )\n .some((pathInfo) => {\n let breakLoop = false;\n const value = get({\n target: copied,\n path: pathInfo.origin,\n pathDelimiter,\n failWithError,\n });\n if (typeof value !== 'undefined') {\n if (pathInfo.customDest) {\n const withCustomProp = set({\n target: result,\n path: pathInfo.dest,\n value,\n pathDelimiter,\n failWithError,\n });\n if (typeof withCustomProp === 'undefined') {\n breakLoop = true;\n failed = true;\n } else {\n result = withCustomProp;\n }\n } else {\n result[pathInfo.dest] = value;\n }\n }\n\n return breakLoop;\n });\n\n if (failed) return undefined;\n return result as T;\n};\n","import { copy } from './copy.js';\nimport { merge } from './merge.js';\n\n/**\n * Checks whether a key for an array or an Object should be flattened.\n *\n * @param key The key to check inside its parent.\n * @param value The value of the key.\n */\nexport type ShouldFlattenFn = (key: string, value: unknown) => boolean;\n\nexport type FlatOptions = {\n /** The object to transform. */\n target: unknown;\n /**\n * A custom prefix to be added before the name of the properties. This can be used on\n * custom cases and it's also used when the method calls itself in order to flatten a\n * sub object.\n */\n prefix?: string;\n /** The delimiter that will separate the path components. */\n pathDelimiter?: string;\n /**\n * A custom function that can be used in order to tell the function whether an Object or\n * an Array property should be flatten or not.\n */\n shouldFlatten?: ShouldFlattenFn;\n};\n/**\n * Flattens an object properties into a single level dictionary.\n *\n * @example\n * const target = {\n * propOne: {\n * propOneSub: 'Charito!',\n * },\n * propTwo: '!!!',\n * };\n * console.log(flat({ target });\n * // Will output { 'propOne.propOneSub': 'Charito!', propTwo: '!!!' }\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nexport const flat = <T = Record<string, unknown>>(options: FlatOptions): T => {\n const { target, shouldFlatten, pathDelimiter = '.', prefix = '' } = options;\n const useTarget = target as Record<string, unknown>;\n let result: Record<string, unknown> = {};\n const namePrefix = prefix ? `${prefix}${pathDelimiter}` : '';\n Object.keys(useTarget).forEach((key) => {\n const name = `${namePrefix}${key}`;\n const value = useTarget[key] as unknown;\n const valueType = typeof value;\n const isObject = valueType === 'object' && value !== null;\n if (isObject && (!shouldFlatten || shouldFlatten(key, value))) {\n result = merge(\n result,\n flat({ target: value, pathDelimiter, prefix: name, shouldFlatten }),\n );\n } else {\n result[name] = isObject ? copy(value) : value;\n }\n });\n\n return result as T;\n};\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from `lowerCamelCase`\n * to `dash-case`.\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nexport const lowerCamelToDashKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])([A-Z])/g,\n replace: (_, firstLetter, secondLetter) => {\n const newSecondLetter = secondLetter.toLowerCase();\n return `${firstLetter}-${newSecondLetter}`;\n },\n });\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from\n * `lowerCamelCase` to `snake_case`.\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nexport const lowerCamelToSnakeKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])([A-Z])/g,\n replace: (_, firstLetter, secondLetter) => {\n const newSecondLetter = secondLetter.toLowerCase();\n return `${firstLetter}_${newSecondLetter}`;\n },\n });\n","import { copy } from './copy.js';\nimport { get } from './get.js';\n\nexport type RemoveOptions = {\n /** The object from where the property will be removed. */\n target: unknown;\n /** The path to the property. */\n path: string;\n /** The delimiter that will separate the path components. */\n pathDelimiter?: string;\n /**\n * Whether or not to throw an error when the path is invalid. If this is `false`, the\n * function will silently fail.\n */\n failWithError?: boolean;\n /**\n * If this flag is `true` and after removing the property the parent object is empty, it\n * will remove it recursively until a non empty parent object is found.\n */\n cleanEmptyProperties?: boolean;\n};\n/**\n * Deletes a property of an object using a path.\n *\n * @example\n * const target = {\n * propOne: {\n * propOneSub: 'Charito!',\n * },\n * propTwo: '!!!',\n * };\n * console.log(remove({ target, path: 'propOne.propOneSub' }));\n * // Will output { propTwo: '!!!' }\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nfunction remove<T = unknown>(options: RemoveOptions): T | undefined;\nfunction remove<T = unknown>(options: unknown, path: string): T | undefined;\nfunction remove<T = unknown>(\n options: RemoveOptions | unknown,\n path?: string,\n): T | undefined {\n let useOptions: RemoveOptions;\n if (typeof path === 'string') {\n useOptions = {\n target: options,\n path,\n };\n } else {\n useOptions = options as RemoveOptions;\n }\n\n const {\n target,\n path: usePath,\n pathDelimiter = '.',\n cleanEmptyProperties = true,\n failWithError = false,\n } = useOptions;\n\n const parts = usePath.split(pathDelimiter);\n const last = parts.pop()!;\n const result = copy(target) as Record<string, unknown>;\n if (!parts.length) {\n delete result[last];\n return result as T;\n }\n const parentPath = parts.join(pathDelimiter);\n const parentObj = get<Record<string, unknown>>({\n target: result,\n path: parentPath,\n pathDelimiter,\n failWithError,\n });\n\n if (typeof parentObj === 'undefined') {\n return undefined;\n }\n\n delete parentObj[last];\n if (cleanEmptyProperties && !Object.keys(parentObj).length) {\n return remove({\n target: result,\n path: parentPath,\n pathDelimiter,\n failWithError,\n cleanEmptyProperties,\n }) as T;\n }\n\n return result as T;\n}\n\nexport { remove };\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from `snake_case` to\n * `dash-case`.\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nexport const snakeToDashKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])_([a-z])/g,\n replace: (_, firstLetter, secondLetter) => `${firstLetter}-${secondLetter}`,\n });\n","import { formatKeys, type FormatKeysExtensionOptions } from './formatKeys.js';\n\n/**\n * A shorthand method for {@link formatKeys} that transforms the keys from `snake_case` to\n * `lowerCamelCase`.\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nexport const snakeToLowerCamelKeys = <T>(options: FormatKeysExtensionOptions): T =>\n formatKeys<T>({\n ...options,\n search: /([a-z])_([a-z])/g,\n replace: (_, firstLetter, secondLetter) => {\n const newSecondLetter = secondLetter.toUpperCase();\n return `${firstLetter}${newSecondLetter}`;\n },\n });\n","import { set } from './set.js';\n\nexport type UnflatOptions = {\n /** The object to transform. */\n target: unknown;\n /** The delimiter that will separate the path components. */\n pathDelimiter?: string;\n};\n/**\n * This method does the exact opposite from `flat`: It takes an already flatten object and\n * restores it structure.\n *\n * @example\n * const target = {\n * 'propOne.propOneSub': 'Charito!',\n * propTwo: '!!!',\n * };\n * console.log(unflat({ target }));\n * // Will output { propOne: { propOneSub: 'Charito!' }, 'propTwo': '!!!' }\n *\n * @template T The type of the returned object.\n * @param options The options to use.\n */\nexport const unflat = <T = Record<string, unknown>>(options: UnflatOptions): T => {\n const { target, pathDelimiter = '.' } = options;\n const useTarget = target as Record<string, unknown>;\n return Object.keys(useTarget).reduce<Record<string, unknown>>(\n (current, key) =>\n set({ target: current, path: key, value: useTarget[key], pathDelimiter })!,\n {},\n ) as T;\n};\n"],"mappings":"AAAA,OAAOA,MAAY,SAsBZ,IAAMC,EAAQ,IAAiBC,IAA0B,CAC9D,GAAM,CAACC,CAAW,EAAID,EAChBE,EAAO,MAAM,QAAQD,CAAW,EAAI,CAAC,EAAI,CAAC,EAChD,OAAOH,EAAO,GAAMI,EAAM,GAAGF,CAAO,CACtC,EClBO,IAAMG,EAAWC,GAAiBC,EAAMD,CAAM,ECmD9C,IAAME,EACXC,GACM,CACN,GAAM,CACJ,OAAAC,EACA,OAAAC,EACA,QAAAC,EACA,QAAAC,EAAU,CAAC,EACX,QAAAC,EAAU,CAAC,EACX,cAAAC,EAAgB,GAClB,EAAIN,EAEEO,EAAYN,EAEZO,EAAO,OAAO,KAAKP,CAAiC,EASpDQ,EAA4C,CAAC,EACnDD,EAAK,QAASE,GAAQ,CACpB,IAAMC,EAAQJ,EAAUG,CAAG,EAC3BD,EAAiBC,CAAG,EAAI,CAAC,EACvBC,GACA,OAAOA,GAAU,UACjBA,IAAU,MACV,CAAC,MAAM,QAAQA,CAAK,GACpB,OAAO,KAAKA,CAAK,EAErB,CAAC,EAOD,IAAMC,EAAuBN,EAAc,QAAQ,2BAA4B,MAAM,EAC/EO,EAA2B,IAAI,OAAO,IAAID,CAAoB,GAAI,GAAG,EACrEE,EAAyB,IAAI,OAAO,GAAGF,CAAoB,IAAK,GAAG,EASnEG,EAA4C,CAAC,EAS/CC,EAEAZ,EAAQ,OACVY,EAAeZ,EACZ,IAAKa,GAAgB,CAEpB,IAAMC,EAAiBD,EACpB,QAAQJ,EAA0B,EAAE,EACpC,QAAQC,EAAwB,EAAE,EAEjCJ,EAEJ,GA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,CACZ,OAAQW,EACR,KAAME,EACN,cAAAP,EACA,cAAAE,EACA,qBAAAD,CACF,CAAC,EAGII,CACT,CCnFO,IAAMK,GAAsBC,GACjCC,EAAc,CACZ,GAAGD,EACH,OAAQ,mBACR,QAAS,CAACE,EAAGC,EAAaC,IAAiB,GAAGD,CAAW,IAAIC,CAAY,EAC3E,CAAC,ECLI,IAAMC,GAA4BC,GACvCC,EAAc,CACZ,GAAGD,EACH,OAAQ,mBACR,QAAS,CAACE,EAAGC,EAAaC,IAAiB,CACzC,IAAMC,EAAkBD,EAAa,YAAY,EACjD,MAAO,GAAGD,CAAW,GAAGE,CAAe,EACzC,CACF,CAAC,ECMI,IAAMC,GAAuCC,GAA8B,CAChF,GAAM,CAAE,OAAAC,EAAQ,cAAAC,EAAgB,GAAI,EAAIF,EAClCG,EAAYF,EAClB,OAAO,OAAO,KAAKE,CAAS,EAAE,OAC5B,CAACC,EAASC,IACRC,EAAI,CAAE,OAAQF,EAAS,KAAMC,EAAK,MAAOF,EAAUE,CAAG,EAAG,cAAAH,CAAc,CAAC,EAC1E,CAAC,CACH,CACF","names":["extend","merge","targets","firstTarget","base","copy","target","merge","formatKeys","options","target","search","replace","include","exclude","pathDelimiter","useTarget","keys","hasChildrenByKey","key","value","escapedPathDelimiter","cleanPathStartExpression","cleanPathEndExpression","subIncludeByKey","keysToFormat","includePath","useIncludePath","pathParts","pathKey","subExcludeByKey","keysToRemove","excludePath","useExcludePath","newObj","newKey","newValue","dashToLowerCamelKeys","options","formatKeys","_","firstLetter","secondLetter","newSecondLetter","dashToSnakeKeys","options","formatKeys","_","firstLetter","secondLetter","get","options","path","useOptions","target","usePath","pathDelimiter","failWithError","useTarget","parts","first","currentElement","currentPath","currentPart","breakLoop","FORBIDDEN_PATHS","set","options","path","value","useOptions","target","usePath","useValue","pathDelimiter","failWithError","result","copy","parts","part","last","currentElement","currentPath","foundInvalid","elementType","errorPath","extract","options","target","paths","pathDelimiter","failWithError","copied","copy","result","failed","acc","objPath","destPath","originPath","firstKey","pathInfo","breakLoop","value","get","withCustomProp","set","flat","options","target","shouldFlatten","pathDelimiter","prefix","useTarget","result","namePrefix","key","name","value","isObject","merge","copy","lowerCamelToDashKeys","options","formatKeys","_","firstLetter","secondLetter","newSecondLetter","lowerCamelToSnakeKeys","options","formatKeys","_","firstLetter","secondLetter","newSecondLetter","remove","options","path","useOptions","target","usePath","pathDelimiter","cleanEmptyProperties","failWithError","parts","last","result","copy","parentPath","parentObj","get","snakeToDashKeys","options","formatKeys","_","firstLetter","secondLetter","snakeToLowerCamelKeys","options","formatKeys","_","firstLetter","secondLetter","newSecondLetter","unflat","options","target","pathDelimiter","useTarget","current","key","set"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@homer0/object-utils",
3
3
  "description": "A small collection of utility methods to work with objects.",
4
- "version": "6.0.2",
4
+ "version": "6.0.4",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/homer0/packages.git",
@@ -37,8 +37,8 @@
37
37
  "extend": "^3.0.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@homer0/oxlint-config": "0.3.0",
41
- "@homer0/tsconfig": "5.0.0",
40
+ "@homer0/oxlint-config": "1.0.2",
41
+ "@homer0/tsconfig": "5.0.1",
42
42
  "@types/extend": "^3.0.4",
43
43
  "@vitest/coverage-v8": "catalog:",
44
44
  "oxlint": "catalog:",
@@ -59,5 +59,5 @@
59
59
  "build": "tsup",
60
60
  "prepublishOnly": "pnpm run build"
61
61
  },
62
- "gitHead": "07328e8a7b1f1b73c46837692c8821a7badca190"
62
+ "gitHead": "e494ba08d9dd4fe6e5d3a9ef54201f3c1f748355"
63
63
  }