Comparing version 1.4.4 to 1.5.0
@@ -0,1 +1,5 @@ | ||
# [1.5.0](https://github.com/KyleAMathews/deepmerge/releases/tag/v1.5.0) | ||
- bug fix: merging objects into arrays was allowed, and doesn't make any sense. [#65](https://github.com/KyleAMathews/deepmerge/issues/65) published as a feature release instead of a patch because it is a decent behavior change. | ||
# [1.4.4](https://github.com/KyleAMathews/deepmerge/releases/tag/v1.4.4) | ||
@@ -2,0 +6,0 @@ |
@@ -59,8 +59,12 @@ 'use strict'; | ||
function deepmerge(target, source, optionsArgument) { | ||
var array = Array.isArray(source); | ||
var sourceIsArray = Array.isArray(source); | ||
var targetIsArray = Array.isArray(target); | ||
var options = optionsArgument || { arrayMerge: defaultArrayMerge }; | ||
var arrayMerge = options.arrayMerge || defaultArrayMerge; | ||
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; | ||
if (array) { | ||
return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument) | ||
if (!sourceAndTargetTypesMatch) { | ||
return cloneIfNecessary(source, optionsArgument) | ||
} else if (sourceIsArray) { | ||
var arrayMerge = options.arrayMerge || defaultArrayMerge; | ||
return arrayMerge(target, source, optionsArgument) | ||
} else { | ||
@@ -67,0 +71,0 @@ return mergeObject(target, source, optionsArgument) |
@@ -57,8 +57,12 @@ var index$2 = function isMergeableObject(value) { | ||
function deepmerge(target, source, optionsArgument) { | ||
var array = Array.isArray(source); | ||
var sourceIsArray = Array.isArray(source); | ||
var targetIsArray = Array.isArray(target); | ||
var options = optionsArgument || { arrayMerge: defaultArrayMerge }; | ||
var arrayMerge = options.arrayMerge || defaultArrayMerge; | ||
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; | ||
if (array) { | ||
return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument) | ||
if (!sourceAndTargetTypesMatch) { | ||
return cloneIfNecessary(source, optionsArgument) | ||
} else if (sourceIsArray) { | ||
var arrayMerge = options.arrayMerge || defaultArrayMerge; | ||
return arrayMerge(target, source, optionsArgument) | ||
} else { | ||
@@ -65,0 +69,0 @@ return mergeObject(target, source, optionsArgument) |
@@ -63,8 +63,12 @@ (function (global, factory) { | ||
function deepmerge(target, source, optionsArgument) { | ||
var array = Array.isArray(source); | ||
var sourceIsArray = Array.isArray(source); | ||
var targetIsArray = Array.isArray(target); | ||
var options = optionsArgument || { arrayMerge: defaultArrayMerge }; | ||
var arrayMerge = options.arrayMerge || defaultArrayMerge; | ||
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; | ||
if (array) { | ||
return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument) | ||
if (!sourceAndTargetTypesMatch) { | ||
return cloneIfNecessary(source, optionsArgument) | ||
} else if (sourceIsArray) { | ||
var arrayMerge = options.arrayMerge || defaultArrayMerge; | ||
return arrayMerge(target, source, optionsArgument) | ||
} else { | ||
@@ -71,0 +75,0 @@ return mergeObject(target, source, optionsArgument) |
12
index.js
@@ -44,8 +44,12 @@ var isMergeableObject = require('is-mergeable-object') | ||
function deepmerge(target, source, optionsArgument) { | ||
var array = Array.isArray(source) | ||
var sourceIsArray = Array.isArray(source) | ||
var targetIsArray = Array.isArray(target) | ||
var options = optionsArgument || { arrayMerge: defaultArrayMerge } | ||
var arrayMerge = options.arrayMerge || defaultArrayMerge | ||
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray | ||
if (array) { | ||
return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument) | ||
if (!sourceAndTargetTypesMatch) { | ||
return cloneIfNecessary(source, optionsArgument) | ||
} else if (sourceIsArray) { | ||
var arrayMerge = options.arrayMerge || defaultArrayMerge | ||
return arrayMerge(target, source, optionsArgument) | ||
} else { | ||
@@ -52,0 +56,0 @@ return mergeObject(target, source, optionsArgument) |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "1.4.4", | ||
"version": "1.5.0", | ||
"homepage": "https://github.com/KyleAMathews/deepmerge", | ||
@@ -16,0 +16,0 @@ "repository": { |
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
21132
316