github-pages-deploy-action/node_modules/@octokit/endpoint/dist-src/util/merge-deep.js

17 lines
538 B
JavaScript
Raw Normal View History

2020-01-28 13:08:03 +08:00
import isPlainObject from "is-plain-object";
export function mergeDeep(defaults, options) {
const result = Object.assign({}, defaults);
2020-06-06 22:11:37 +08:00
Object.keys(options).forEach((key) => {
2020-01-28 13:08:03 +08:00
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;
}