mixer-client-node
Version:
A node client for connecting to mixer and the mixer services
36 lines (35 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toJSON = exports.mergeDeep = exports.isObject = void 0;
function isObject(item) {
return item && typeof item === 'object' && !Array.isArray(item);
}
exports.isObject = isObject;
function mergeDeep(target, source) {
const output = { ...target };
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach((key) => {
if (isObject(source[key])) {
if (!(key in target))
Object.assign(output, { [key]: source[key] });
else
output[key] = mergeDeep(target[key], source[key]);
}
else {
Object.assign(output, { [key]: source[key] });
}
});
}
return output;
}
exports.mergeDeep = mergeDeep;
function toJSON(source) {
try {
const parsedJSON = JSON.parse(source);
return parsedJSON;
}
catch (error) {
return {};
}
}
exports.toJSON = toJSON;