@homer0/object-utils 5.0.2 → 5.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 +406 -0
- package/package.json +6 -7
- package/src/fns/copy.ts +0 -10
- package/src/fns/dashToLowerCamelKeys.ts +0 -18
- package/src/fns/dashToSnakeKeys.ts +0 -15
- package/src/fns/extract.ts +0 -120
- package/src/fns/flat.ts +0 -71
- package/src/fns/formatKeys.ts +0 -270
- package/src/fns/get.ts +0 -93
- package/src/fns/lowerCamelToDashKeys.ts +0 -18
- package/src/fns/lowerCamelToSnakeKeys.ts +0 -18
- package/src/fns/merge.ts +0 -29
- package/src/fns/remove.ts +0 -102
- package/src/fns/set.ts +0 -131
- package/src/fns/snakeToDashKeys.ts +0 -15
- package/src/fns/snakeToLowerCamelKeys.ts +0 -18
- package/src/fns/unflat.ts +0 -37
- package/src/index.ts +0 -15
package/src/fns/unflat.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { set } from './set.js';
|
|
2
|
-
|
|
3
|
-
export type UnflatOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* The object to transform.
|
|
6
|
-
*/
|
|
7
|
-
target: unknown;
|
|
8
|
-
/**
|
|
9
|
-
* The delimiter that will separate the path components.
|
|
10
|
-
*/
|
|
11
|
-
pathDelimiter?: string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* This method does the exact opposite from `flat`: It takes an already flatten object and
|
|
15
|
-
* restores it structure.
|
|
16
|
-
*
|
|
17
|
-
* @param options The options to use.
|
|
18
|
-
* @template T The type of the returned object.
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* const target = {
|
|
22
|
-
* 'propOne.propOneSub': 'Charito!',
|
|
23
|
-
* propTwo: '!!!',
|
|
24
|
-
* };
|
|
25
|
-
* console.log(unflat({ target }));
|
|
26
|
-
* // Will output { propOne: { propOneSub: 'Charito!' }, 'propTwo': '!!!' }
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
export const unflat = <T = Record<string, unknown>>(options: UnflatOptions): T => {
|
|
30
|
-
const { target, pathDelimiter = '.' } = options;
|
|
31
|
-
const useTarget = target as Record<string, unknown>;
|
|
32
|
-
return Object.keys(useTarget).reduce<Record<string, unknown>>(
|
|
33
|
-
(current, key) =>
|
|
34
|
-
set({ target: current, path: key, value: useTarget[key], pathDelimiter })!,
|
|
35
|
-
{},
|
|
36
|
-
) as T;
|
|
37
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './fns/copy.js';
|
|
2
|
-
export * from './fns/dashToLowerCamelKeys.js';
|
|
3
|
-
export * from './fns/dashToSnakeKeys.js';
|
|
4
|
-
export * from './fns/extract.js';
|
|
5
|
-
export * from './fns/flat.js';
|
|
6
|
-
export * from './fns/formatKeys.js';
|
|
7
|
-
export * from './fns/get.js';
|
|
8
|
-
export * from './fns/lowerCamelToDashKeys.js';
|
|
9
|
-
export * from './fns/lowerCamelToSnakeKeys.js';
|
|
10
|
-
export * from './fns/merge.js';
|
|
11
|
-
export * from './fns/remove.js';
|
|
12
|
-
export * from './fns/set.js';
|
|
13
|
-
export * from './fns/snakeToDashKeys.js';
|
|
14
|
-
export * from './fns/snakeToLowerCamelKeys.js';
|
|
15
|
-
export * from './fns/unflat.js';
|