Files
k8s-set-context/node_modules/openid-client/lib/helpers/merge.js
github-actions[bot] 52d71d28bd Add node modules and compiled JavaScript from main (#54)
Co-authored-by: Oliver King <oking3@uncc.edu>
2022-06-29 15:41:55 -04:00

27 lines
681 B
JavaScript

/* eslint-disable no-restricted-syntax, no-param-reassign, no-continue */
const isPlainObject = require('./is_plain_object');
function merge(target, ...sources) {
for (const source of sources) {
if (!isPlainObject(source)) {
continue;
}
for (const [key, value] of Object.entries(source)) {
/* istanbul ignore if */
if (key === '__proto__' || key === 'constructor') {
continue;
}
if (isPlainObject(target[key]) && isPlainObject(value)) {
target[key] = merge(target[key], value);
} else if (typeof value !== 'undefined') {
target[key] = value;
}
}
}
return target;
}
module.exports = merge;