Philipp Horstenkamp 6e037d6837
Some checks failed
Auto Maintenance Cycle / pre-commit Autoupdate (push) Failing after 33s
Added the node modules.
2023-11-19 03:45:16 +01:00

17 lines
542 B
JavaScript

import { isPlainObject } from "is-plain-object";
export function mergeDeep(defaults, options) {
const result = Object.assign({}, defaults);
Object.keys(options).forEach((key) => {
if (isPlainObject(options[key])) {
if (!(key in defaults))
Object.assign(result, { [key]: options[key] });
else
result[key] = mergeDeep(defaults[key], options[key]);
}
else {
Object.assign(result, { [key]: options[key] });
}
});
return result;
}