Socket
Socket
Sign inDemoInstall

deepmerge

Package Overview
Dependencies
0
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.1 to 2.2.0

index.d.ts

4

changelog.md

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

# # [2.2.0](https://github.com/KyleAMathews/deepmerge/releases/tag/v2.2.0)
- feature: added TypeScript typings [#119](https://github.com/KyleAMathews/deepmerge/pull/119)
# [2.1.1](https://github.com/KyleAMathews/deepmerge/releases/tag/v2.1.1)

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

5

package.json

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

],
"version": "2.1.1",
"version": "2.2.0",
"homepage": "https://github.com/KyleAMathews/deepmerge",

@@ -27,3 +27,3 @@ "repository": {

"build": "rollup -c",
"test": "npm run build && tap test/*.js && jsmd readme.md",
"test": "npm run build && tap test/*.js && jsmd readme.md && tsc --noEmit test/typescript.ts",
"size": "npm run build && uglifyjs --compress --mangle -- ./dist/umd.js | gzip -c | wc -c"

@@ -39,2 +39,3 @@ },

"tap": "~7.1.2",
"typescript": "=2.2.2",
"uglify-js": "^3.3.12"

@@ -41,0 +42,0 @@ },

@@ -113,2 +113,3 @@ # deepmerge

**Note:** By default, arrays are merged by concatenating them.

@@ -133,15 +134,12 @@ ## `merge.all(arrayOfObjects, [options])`

### `arrayMerge`
deepmerge, by default, concatenates arrays and merges array values.
There are however nigh-infinite valid ways to merge arrays, and you may want to supply your own method. You can do this by passing an `arrayMerge` function as an option.
There are multiple ways to merge two arrays, below are a few examples but you can also create your own custom function.
The options object will include the default `isMergeableObject` implementation if the top-level consumer didn't pass a custom function in.
#### Overwrite Array
Overwrites the existing array values completely rather than concatenating them
#### Examples
Example of overwriting merge when merging arrays:
```js
const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray
merge(

@@ -154,12 +152,5 @@ [1, 2, 3],

Example of preventing arrays inside of objects from being merged:
#### Combine Array
```js
const dontMerge = (destination, source) => source
merge(
{ coolThing: [1, 2, 3] },
{ coolThing: ['a', 'b', 'c'] },
{ arrayMerge: dontMerge }
) // => { coolThing: ['a', 'b', 'c'] }
```
Combine arrays, such as overwriting existing defaults while also adding/keeping values that are different names

@@ -172,3 +163,3 @@ To use the legacy (pre-version-2.0.0) array merging algorithm, use the following:

function legacyArrayMerge(target, source, options) {
function combineMerge(target, source, options) {
const destination = target.slice()

@@ -193,7 +184,6 @@

[{ b: true }, 'ah yup'],
{ arrayMerge: legacyArrayMerge }
{ arrayMerge: combineMerge }
) // => [{ a: true, b: true }, 'ah yup']
```
### `isMergeableObject`

@@ -200,0 +190,0 @@

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