Files
automatisch/packages/web/src/helpers/nestObject.ts
2024-01-15 13:30:48 +01:00

19 lines
404 B
TypeScript

import { IJSONObject } from 'types';
import set from 'lodash/set';
export default function nestObject<T = IJSONObject>(
config: IJSONObject | undefined
): Partial<T> {
if (!config) return {};
const result = {};
for (const key in config) {
if (Object.prototype.hasOwnProperty.call(config, key)) {
const value = config[key];
set(result, key, value);
}
}
return result;
}