@n3okill/utils
Version:
Many javascript helpers
34 lines • 1.46 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.deepMixIn = deepMixIn;
const isPlainObject_1 = require("../type/isPlainObject");
const mixIn_1 = require("./mixIn");
/**
* Merge given objects into a new one without cloning values
* @param args Objects to be merged
* @returns The new merged object
*/
function deepMixIn(...args) {
if (args.length === 0)
return {};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const target = args.shift();
for (const obj of args) {
for (const [key, value] of Object.entries(obj)) {
if (!Object.prototype.hasOwnProperty.call(target, key)) {
// eslint-disable-next-line security/detect-object-injection, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
target[key] = value;
// eslint-disable-next-line security/detect-object-injection, @typescript-eslint/no-unsafe-member-access
}
else if ((0, isPlainObject_1.isPlainObject)(target[key]) && (0, isPlainObject_1.isPlainObject)(value)) {
// eslint-disable-next-line security/detect-object-injection, @typescript-eslint/no-unsafe-member-access
deepMixIn(target[key], value);
}
else {
(0, mixIn_1.mixIn)(target, obj);
}
}
}
return target;
}
//# sourceMappingURL=deepMixIn.js.map
;