Comparing version 1.1.0 to 1.1.1
@@ -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 @@ |
@@ -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'] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16586
407