You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@fastify/deepmerge

Package Overview
Dependencies
Maintainers
17
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/deepmerge - npm Package Compare versions

Comparing version
3.1.0
to
3.2.0
+9
-0
index.js

@@ -86,2 +86,4 @@ 'use strict'

const onlyDefinedProperties = options?.onlyDefinedProperties === true
function isPrimitive (value) {

@@ -128,2 +130,5 @@ return typeof value !== 'object' || value === null

} else {
if (onlyDefinedProperties && typeof source[key] === 'undefined') {
continue
}
result[key] = clone(source[key])

@@ -136,2 +141,6 @@ }

function _deepmerge (target, source) {
if (onlyDefinedProperties && typeof source === 'undefined') {
return clone(target)
}
const sourceIsArray = Array.isArray(source)

@@ -138,0 +147,0 @@ const targetIsArray = Array.isArray(target)

+3
-4
MIT License
Copyright (c) The Fastify Team
Copyright (c) 2022-present The Fastify team
The Fastify team members are listed at https://github.com/fastify/fastify#team
and in the README file.
The Fastify team members are listed at https://github.com/fastify/fastify#team.

@@ -24,2 +23,2 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
{
"name": "@fastify/deepmerge",
"version": "3.1.0",
"version": "3.2.0",
"description": "Merges the enumerable properties of two or more objects deeply.",

@@ -59,3 +59,3 @@ "main": "index.js",

"c8": "^10.1.3",
"tsd": "^0.31.1"
"tsd": "^0.33.0"
},

@@ -62,0 +62,0 @@ "files": [

@@ -31,2 +31,3 @@ # @fastify/deepmerge

- `isMergeableObject` (`function`, optional) - provide a function, which must return true if the object should be merged, default is `isMergeableObject` from this module
- `onlyDefinedProperties` (`boolean`, optional) - if `true`, properties with `undefined` in the source will not overwrite existing values from the target, default is `false`

@@ -45,2 +46,10 @@ ```js

Example with `onlyDefinedProperties` option:
```js
const deepmerge = require('@fastify/deepmerge')({ onlyDefinedProperties: true })
const result = deepmerge({ a: 1, b: null }, { a: undefined, b: undefined })
console.log(result) // { a: 1, b: null }
```
#### mergeArray

@@ -47,0 +56,0 @@

@@ -71,2 +71,3 @@ type DeepMergeFn = <T1, T2>(target: T1, source: T2) => DeepMerge<T1, T2>

type CloneProtoObjectFn = (value: any) => any
type MergeArrayFn = (options: MergeArrayFnOptions) => (target: any[], source: any[]) => any[]

@@ -80,2 +81,7 @@

all?: boolean;
/**
* If true, ignore undefined values from source and keep existing target values.
* Defaults to false.
*/
onlyDefinedProperties?: boolean;
}

@@ -94,4 +100,5 @@

declare function deepmerge (options: Options & { all: true }): DeepMergeAllFn
declare function deepmerge (options?: Options): DeepMergeFn
export = deepmerge