EnokMan a0ac4f99d2
Some checks failed
Setup ossutil / build (push) Failing after 25s
bump deps
2020-11-10 04:40:33 +00: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;
}