Socket
Socket
Sign inDemoInstall

deepmerge

Package Overview
Dependencies
0
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 4.1.0

4

changelog.md

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

# [4.1.0](https://github.com/TehShrike/deepmerge/releases/tag/v4.1.0)
- `cloneUnlessOtherwiseSpecified` is now exposed to the `arrayMerge` function [#165](https://github.com/TehShrike/deepmerge/pull/165)
# [4.0.0](https://github.com/TehShrike/deepmerge/releases/tag/v4.0.0)

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

@@ -85,2 +85,5 @@ 'use strict';

options.isMergeableObject = options.isMergeableObject || isMergeableObject;
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
// implementations can use it. The caller may not replace it.
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;

@@ -87,0 +90,0 @@ var sourceIsArray = Array.isArray(source);

@@ -89,2 +89,5 @@ (function (global, factory) {

options.isMergeableObject = options.isMergeableObject || isMergeableObject;
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
// implementations can use it. The caller may not replace it.
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;

@@ -91,0 +94,0 @@ var sourceIsArray = Array.isArray(source);

@@ -60,2 +60,5 @@ var defaultIsMergeableObject = require('is-mergeable-object')

options.isMergeableObject = options.isMergeableObject || defaultIsMergeableObject
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
// implementations can use it. The caller may not replace it.
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified

@@ -62,0 +65,0 @@ var sourceIsArray = Array.isArray(source)

2

package.json

@@ -12,3 +12,3 @@ {

],
"version": "4.0.0",
"version": "4.1.0",
"homepage": "https://github.com/TehShrike/deepmerge",

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

@@ -110,6 +110,11 @@ # deepmerge

#### Overwrite Array
Your `arrayMerge` function will be called with three arguments: a `target` array, the `source` array, and an `options` object with these properties:
Overwrites the existing array values completely rather than concatenating them
- `isMergeableObject(value)`
- `cloneUnlessOtherwiseSpecified(value, options)`
#### `arrayMerge` example: overwrite target array
Overwrites the existing array values completely rather than concatenating them:
```js

@@ -125,12 +130,9 @@ const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray

#### Combine Array
#### `arrayMerge` example: combine arrays
Combine arrays, such as overwriting existing defaults while also adding/keeping values that are different names
Combines objects at the same index in the two arrays.
To use the legacy (pre-version-2.0.0) array merging algorithm, use the following:
This was the default array merging algorithm pre-version-2.0.0.
```js
const emptyTarget = value => Array.isArray(value) ? [] : {}
const clone = (value, options) => merge(emptyTarget(value), value, options)
const combineMerge = (target, source, options) => {

@@ -141,5 +143,3 @@ const destination = target.slice()

if (typeof destination[index] === 'undefined') {
const cloneRequested = options.clone !== false
const shouldClone = cloneRequested && options.isMergeableObject(item)
destination[index] = shouldClone ? clone(item, options) : item
destination[index] = options.cloneUnlessOtherwiseSpecified(item, options)
} else if (options.isMergeableObject(item)) {

@@ -146,0 +146,0 @@ destination[index] = merge(target[index], item, options)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc