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

deepmerge

Package Overview
Dependencies
Maintainers
4
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 1.1.0 to 1.1.1

4

changelog.md

@@ -0,1 +1,5 @@

# [1.1.1](https://github.com/KyleAMathews/deepmerge/releases/tag/v1.1.0)
- fix an issue where an error was thrown when merging an array onto a non-array: [Pull request 46](https://github.com/KyleAMathews/deepmerge/pull/46)
# [1.1.0](https://github.com/KyleAMathews/deepmerge/releases/tag/v1.1.0)

@@ -2,0 +6,0 @@

3

index.js

@@ -56,4 +56,3 @@ (function (root, factory) {

if (array) {
target = target || [];
return arrayMerge(target, source, optionsArgument)
return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : source.slice()
} else {

@@ -60,0 +59,0 @@ return mergeObject(target, source, optionsArgument)

@@ -13,3 +13,3 @@ {

],
"version": "1.1.0",
"version": "1.1.1",
"homepage": "https://github.com/KyleAMathews/deepmerge",

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

@@ -132,2 +132,53 @@ var merge = require('../')

test('should replace objects with arrays', function(t) {
var target = [
{ key1: { subkey: 'one' }}
]
var src = [
{ key1: [ "subkey" ]}
]
var expected = [
{ key1: [ "subkey" ]}
]
t.deepEqual(merge(target, src), expected)
t.end()
})
test('should replace dates with arrays', function(t) {
var target = [
{ key1: new Date()}
]
var src = [
{ key1: [ "subkey" ]}
]
var expected = [
{ key1: [ "subkey" ]}
]
t.deepEqual(merge(target, src), expected)
t.end()
})
test('should replace null with arrays', function(t) {
var target = {
key1: null
}
var src = {
key1: [ "subkey" ]
}
var expected = {
key1: [ "subkey" ]
}
t.deepEqual(merge(target, src), expected)
t.end()
})
test('should work on simple array', function (t) {

@@ -267,2 +318,23 @@ var src = ['one', 'three']

test('should overwrite values when property is initialised but undefined', function(t) {
var target1 = { value: [] }
var target2 = { value: null }
var target3 = { value: 2 }
var src = { value: undefined }
var expected = { value: undefined }
function hasUndefinedProperty(o) {
t.ok(o.hasOwnProperty('value'))
t.type(o.value, 'undefined')
}
hasUndefinedProperty(merge(target1, src))
hasUndefinedProperty(merge(target2, src))
hasUndefinedProperty(merge(target3, src))
t.end()
})
test('null should be equal to null in an array', function(t) {

@@ -269,0 +341,0 @@ var target = [null, 'dude']

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