open-epsilon
Version:
empty-epsilon / open-sound-control bidirectional proxy
33 lines • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.merge = void 0;
function merge(json1, json2) {
let result = json2;
if (json2 && typeof json2 === 'object' && !Array.isArray(json2)) {
result = {};
if (json1 && typeof json1 === 'object' && !Array.isArray(json1)) {
for (let key in json1) {
result[key] = json1[key];
}
}
for (let key in json2) {
if (typeof result[key] === "object" && typeof json2 === "object") {
result[key] = merge(result[key], json2[key]);
}
else {
result[key] = json2[key];
}
}
}
else if (Array.isArray(json1) && Array.isArray(json2)) {
result = json1;
for (let i = 0; i < json2.length; i++) {
if (result.indexOf(json2[i]) === -1) {
result[result.length] = json2[i];
}
}
}
return result;
}
exports.merge = merge;
//# sourceMappingURL=utils.js.map