@andranik-arakelyan/js-utilities
Version:
Javascript utilities
34 lines (33 loc) • 741 B
TypeScript
/**
* Unflattens a flat object with dot notation keys into a nested object structure.
*
* @param obj - The flattened object to unflatten
* @returns A nested object structure
*
* @example
* ```ts
* const flattened = {
* 'user.profile.name': 'John',
* 'user.profile.age': 30,
* 'user.settings.theme': 'dark',
* 'app.version': '1.0.0'
* };
*
* const nested = unflattenObject(flattened);
* // {
* // user: {
* // profile: {
* // name: 'John',
* // age: 30
* // },
* // settings: {
* // theme: 'dark'
* // }
* // },
* // app: {
* // version: '1.0.0'
* // }
* // }
* ```
*/
export declare function unflattenObject(obj: Record<string, any>): Record<string, any>;