Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fastify/deepmerge

Package Overview
Dependencies
Maintainers
18
Versions
5
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 1.1.0 to 1.2.0

16

index.js

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

const JSON_PROTO = Object.getPrototypeOf({})
function deepmergeConstructor (options) {

@@ -30,2 +32,6 @@ function isNotPrototypeKey (value) {

if (cloneProtoObject && Object.getPrototypeOf(target) !== JSON_PROTO) {
return cloneProtoObject(target)
}
const targetKeys = getKeys(target)

@@ -68,2 +74,6 @@ let i, il, key

const cloneProtoObject = typeof options?.cloneProtoObject === 'function'
? options.cloneProtoObject
: undefined
function isMergeableObject (value) {

@@ -77,5 +87,5 @@ return typeof value === 'object' && value !== null && !(value instanceof RegExp) && !(value instanceof Date)

function isPrimitiveOrBuiltIn (value) {
return typeof value !== 'object' || value === null || value instanceof RegExp || value instanceof Date
}
const isPrimitiveOrBuiltIn = typeof Buffer !== 'undefined'
? (value) => typeof value !== 'object' || value === null || value instanceof RegExp || value instanceof Date || value instanceof Buffer
: (value) => typeof value !== 'object' || value === null || value instanceof RegExp || value instanceof Date

@@ -82,0 +92,0 @@ const mergeArray = options && typeof options.mergeArray === 'function'

5

package.json
{
"name": "@fastify/deepmerge",
"version": "1.1.0",
"version": "1.2.0",
"description": "Merges the enumerable properties of two or more objects deeply.",

@@ -27,3 +27,4 @@ "main": "index.js",

"tap": "^16.3.0",
"tsd": "^0.22.0"
"tape": "^5.6.1",
"tsd": "^0.24.1"
},

@@ -30,0 +31,0 @@ "files": [

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

- `mergeArray` (`function`, optional) - provide a function, which returns a function to add custom array merging function
- `cloneProtoObject` (`function`, optional) - provide a function, which must return a clone of the object with the prototype of the object

@@ -116,2 +117,20 @@ ```js

#### cloneProtoObject
Merging objects with prototypes, such as Streams or Buffers, are not supported by default.
You can provide a custom function to let this module deal with the object that has a `prototype` _(JSON object excluded)_.
```js
function cloneByReference (source) {
return source
}
const deepmergeByReference = require('@fastify/deepmerge')({
cloneProtoObject: cloneByReference
})
const result = deepmergeByReference({}, { stream: process.stdout })
console.log(result) // { stream: <ref *1> WriteStream }
```
## Benchmarks

@@ -118,0 +137,0 @@

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