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

putil-merge

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

putil-merge - npm Package Compare versions

Comparing version 3.11.0 to 3.12.0

30

lib/merge.js

@@ -12,3 +12,3 @@ /* putil-merge

* @param {Object} options
* @param {boolean} [options.deep]
* @param {boolean|Function} [options.deep]
* @param {boolean} [options.clone]

@@ -18,3 +18,3 @@ * @param {boolean} [options.combine]

* @param {Function} [options.filter]
* @param {Function|Boolean} [options.arrayMerge]
* @param {Boolean|Function} [options.arrayMerge]
* @return {Object}

@@ -31,2 +31,8 @@ */

throw new TypeError('Property "source" requires object or function type');
const optionDeep = options.deep;
const optionDescriptor = options.descriptor;
const optionClone = options.clone;
const optionFilter = options.filter;
const optionCombine = options.combine;
const optionArrayMerge = options.arrayMerge;

@@ -39,5 +45,5 @@ if (source === target) return target;

continue;
if (options.filter && !options.filter(source, key))
if (optionFilter && !optionFilter(source, key))
continue;
if ((options.combine || options.adjunct) && target.hasOwnProperty(key))
if (optionCombine && target.hasOwnProperty(key))
continue;

@@ -47,3 +53,3 @@

if (options.descriptor && (descriptor.get || descriptor.set)) {
if (optionDescriptor && (descriptor.get || descriptor.set)) {
Object.defineProperty(target, key, descriptor);

@@ -58,3 +64,3 @@ continue;

delete descriptor.set;
if (!options.descriptor) {
if (!optionDescriptor) {
descriptor.enumerable = true;

@@ -67,3 +73,3 @@ descriptor.configurable = true;

if (isPlainObject(srcVal)) {
if (options.deep) {
if (optionDeep === true || (typeof optionDeep === 'function' && optionDeep(srcVal))) {
if (!isObject(trgVal)) {

@@ -76,11 +82,11 @@ descriptor.value = trgVal = {};

}
if (options.clone)
if (optionClone)
srcVal = merge({}, srcVal, options);
} else if (Array.isArray(srcVal)) {
if (options.arrayMerge && Array.isArray(trgVal)) {
if (typeof options.arrayMerge === 'function')
srcVal = options.arrayMerge(trgVal, srcVal);
if (optionArrayMerge && Array.isArray(trgVal)) {
if (typeof optionArrayMerge === 'function')
srcVal = optionArrayMerge(trgVal, srcVal);
else
srcVal = merge.arrayCombine(trgVal, srcVal);
} else if (options.clone)
} else if (optionClone)
srcVal = srcVal.slice();

@@ -87,0 +93,0 @@ }

6

package.json
{
"name": "putil-merge",
"description": "Lightweight solution for merging multiple objects into one. Also it supports deep merge and deep clone",
"version": "3.11.0",
"version": "3.12.0",
"author": "Panates Ltd.",

@@ -23,4 +23,4 @@ "contributors": [

"@types/mocha": "^10.0.2",
"@types/node": "^20.8.2",
"eslint": "^8.50.0",
"@types/node": "^20.8.6",
"eslint": "^8.51.0",
"eslint-config-google": "^0.14.0",

@@ -27,0 +27,0 @@ "mocha": "^10.2.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