@team-supercharge/nest-amqp
Version:
AMQP 1.0 module for Nest framework
29 lines (28 loc) • 903 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extendObject = void 0;
const toString = Object.prototype.toString;
/**
* The source object's properties will be merged to the target object.
*
* @param {Record<string, any>} target Target object.
* @param {Record<string, any>} source Source object which will be merged to target object.
*
* @return {Record<string, any>} The merged object.
*/
function extendObject(target, source) {
const sourceKeys = Object.keys(source);
for (const key of sourceKeys) {
if (toString.call(source[key]) === '[object Object]') {
if (!target[key]) {
target[key] = {};
}
target[key] = extendObject(target[key], source[key]);
}
else {
target[key] = source[key];
}
}
return target;
}
exports.extendObject = extendObject;