Socket
Socket
Sign inDemoInstall

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.1 to 1.2.0

7

changelog.md

@@ -1,3 +0,8 @@

# [1.1.1](https://github.com/KyleAMathews/deepmerge/releases/tag/v1.1.0)
# [1.2.0](https://github.com/KyleAMathews/deepmerge/releases/tag/v1.2.0)
- fix: an error that would be thrown when an array would be merged onto a truthy non-array value: pull request [46](https://github.com/KyleAMathews/deepmerge/pull/46)
- feature: the ability to clone: Issue [28](https://github.com/KyleAMathews/deepmerge/issues/28), pull requests [44](https://github.com/KyleAMathews/deepmerge/pull/44) and [48](https://github.com/KyleAMathews/deepmerge/pull/48)
# [1.1.1](https://github.com/KyleAMathews/deepmerge/releases/tag/v1.1.1)
- 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)

@@ -4,0 +9,0 @@

19

index.js

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

function emptyTarget(val) {
return Array.isArray(val) ? [] : {}
}
function cloneIfNecessary(value, optionsArgument) {
var clone = optionsArgument && optionsArgument.clone === true
return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
}
function defaultArrayMerge(target, source, optionsArgument) {

@@ -24,7 +33,7 @@ var destination = target.slice()

if (typeof destination[i] === 'undefined') {
destination[i] = e
destination[i] = cloneIfNecessary(e, optionsArgument)
} else if (isMergeableObject(e)) {
destination[i] = deepmerge(target[i], e, optionsArgument)
} else if (target.indexOf(e) === -1) {
destination.push(e)
destination.push(cloneIfNecessary(e, optionsArgument))
}

@@ -39,3 +48,3 @@ })

Object.keys(target).forEach(function (key) {
destination[key] = target[key]
destination[key] = cloneIfNecessary(target[key], optionsArgument)
})

@@ -45,3 +54,3 @@ }

if (!isMergeableObject(source[key]) || !target[key]) {
destination[key] = source[key]
destination[key] = cloneIfNecessary(source[key], optionsArgument)
} else {

@@ -60,3 +69,3 @@ destination[key] = deepmerge(target[key], source[key], optionsArgument)

if (array) {
return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : source.slice()
return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument)
} else {

@@ -63,0 +72,0 @@ return mergeObject(target, source, optionsArgument)

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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