New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@corex/deepmerge

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@corex/deepmerge - npm Package Compare versions

Comparing version 2.2.5 to 2.2.6

59

dist/index.js

@@ -1,26 +0,37 @@

Object.defineProperty(exports, "__esModule", { value: true });
const isObject = (obj) => {
if (typeof obj === 'object' && obj !== null) {
if (typeof Object.getPrototypeOf === 'function') {
const prototype = Object.getPrototypeOf(obj);
return prototype === Object.prototype || prototype === null;
}
return Object.prototype.toString.call(obj) === '[object Object]';
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
return false;
};
const merge = (...objects) => objects.reduce((result, current) => {
Object.keys(current).forEach((key) => {
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
result[key] = Array.from(new Set(result[key].concat(current[key])));
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const isObject = (obj) => {
if (typeof obj === 'object' && obj !== null) {
if (typeof Object.getPrototypeOf === 'function') {
const prototype = Object.getPrototypeOf(obj);
return prototype === Object.prototype || prototype === null;
}
return Object.prototype.toString.call(obj) === '[object Object]';
}
else if (isObject(result[key]) && isObject(current[key])) {
result[key] = merge(result[key], current[key]);
}
else {
result[key] = current[key];
}
});
return result;
}, {});
exports.default = merge;
return false;
};
const merge = (...objects) => objects.reduce((result, current) => {
Object.keys(current).forEach((key) => {
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
result[key] = Array.from(new Set(result[key].concat(current[key])));
}
else if (isObject(result[key]) && isObject(current[key])) {
result[key] = merge(result[key], current[key]);
}
else {
result[key] = current[key];
}
});
return result;
}, {});
exports.default = merge;
});
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = __importDefault(require("./index"));
describe('@corex/deepmerge', () => {
test('simple object', () => {
const obj1 = {
a: 1,
b: {
c: 2,
},
};
const obj2 = {
a: 2,
b: {
c: 4,
d: 5,
},
};
expect(index_1.default(obj1, obj2)).toStrictEqual({
a: 2,
b: {
c: 4,
d: 5,
},
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./index"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = __importDefault(require("./index"));
describe('@corex/deepmerge', () => {
test('simple object', () => {
const obj1 = {
a: 1,
b: {
c: 2,
},
};
const obj2 = {
a: 2,
b: {
c: 4,
d: 5,
},
};
expect(index_1.default(obj1, obj2)).toStrictEqual({
a: 2,
b: {
c: 4,
d: 5,
},
});
});
});
test('array', () => {
const arr1 = {
a: [1, 2, 3],
};
const arr2 = {
a: [3, 4, 5],
};
expect(index_1.default(arr1, arr2)).toStrictEqual({
a: [1, 2, 3, 4, 5],
test('array', () => {
const arr1 = {
a: [1, 2, 3],
};
const arr2 = {
a: [3, 4, 5],
};
expect(index_1.default(arr1, arr2)).toStrictEqual({
a: [1, 2, 3, 4, 5],
});
});
});
test('complex object', () => {
const obj1 = {
a: 2,
b: (x, y) => x + y,
c: [1, 2, 4],
d: {
e: [4, 5, 7],
},
};
expect(obj1.b(7, 5)).toStrictEqual(12);
const obj2 = {
a: 10,
b: (x, y) => x / y,
c: [20, 30],
d: {
e: [4, 7, 5],
f: {
g: 'another',
test('complex object', () => {
const obj1 = {
a: 2,
b: (x, y) => x + y,
c: [1, 2, 4],
d: {
e: [4, 5, 7],
},
},
};
const obj3 = {
b: (x, y) => x * y,
c: [1, 2, 4],
d: {
e: [4, 7, 5],
},
};
const result = index_1.default(obj1, obj2, obj3);
expect(result.b(7, 5)).toStrictEqual(35);
};
expect(obj1.b(7, 5)).toStrictEqual(12);
const obj2 = {
a: 10,
b: (x, y) => x / y,
c: [20, 30],
d: {
e: [4, 7, 5],
f: {
g: 'another',
},
},
};
const obj3 = {
b: (x, y) => x * y,
c: [1, 2, 4],
d: {
e: [4, 7, 5],
},
};
const result = index_1.default(obj1, obj2, obj3);
expect(result.b(7, 5)).toStrictEqual(35);
});
});
});
{
"name": "@corex/deepmerge",
"version": "2.2.5",
"version": "2.2.6",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc