Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deepmerge

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deepmerge - npm Package Compare versions

Comparing version 0.2.10 to 1.0.0

changelog.md

16

index.js

@@ -11,2 +11,11 @@ (function (root, factory) {

function isMergeableObject(val) {
var nonNullObject = val && typeof val === 'object'
return nonNullObject
&& Object.prototype.toString.call(val) !== '[object RegExp]'
&& Object.prototype.toString.call(val) !== '[object Date]'
}
return function deepmerge(target, src) {

@@ -31,3 +40,3 @@ var array = Array.isArray(src);

} else {
if (target && typeof target === 'object') {
if (isMergeableObject(target)) {
Object.keys(target).forEach(function (key) {

@@ -38,6 +47,5 @@ dst[key] = target[key];

Object.keys(src).forEach(function (key) {
if (typeof src[key] !== 'object' || !src[key]) {
if (!isMergeableObject(src[key])) {
dst[key] = src[key];
}
else {
} else {
if (!target[key]) {

@@ -44,0 +52,0 @@ dst[key] = src[key];

@@ -5,3 +5,3 @@ {

"description": "A library for deep (recursive) merging of Javascript objects",
"version": "0.2.10",
"version": "1.0.0",
"homepage": "https://github.com/nrf110/deepmerge",

@@ -8,0 +8,0 @@ "repository": {

@@ -223,1 +223,32 @@ var merge = require('../')

})
test('should treat regular expressions like primitive values', function (t) {
var target = { key1: /abc/ }
var src = { key1: /efg/ }
var expected = { key1: /efg/ }
t.deepEqual(merge(target, src), expected)
t.deepEqual(merge(target, src).key1.test('efg'), true)
t.end()
})
test('should treat dates like primitives', function(t) {
var monday = new Date('2016-09-27T01:08:12.761Z')
var tuesday = new Date('2016-09-28T01:18:12.761Z')
var target = {
key: monday
}
var source = {
key: tuesday
}
var expected = {
key: tuesday
}
var actual = merge(target, source)
t.deepEqual(actual, expected)
t.equal(actual.key.valueOf(), tuesday.valueOf())
t.end()
})
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