putil-merge
Advanced tools
Comparing version 3.8.0 to 3.9.0
@@ -7,5 +7,4 @@ /* putil-merge | ||
const isObjectOrClass = (v) => v && ( | ||
(typeof v === 'object' && !Array.isArray(v)) || | ||
(typeof v === 'function' && v.prototype && v.prototype.constructor)); | ||
const isObject = (v) => v && ( | ||
(typeof v === 'object' && !Array.isArray(v))); | ||
@@ -26,7 +25,7 @@ /** | ||
function merge(target, source, options = {}) { | ||
if (!isObjectOrClass(target)) | ||
if (!isObject(target)) | ||
throw new TypeError('Property "target" requires object type'); | ||
if (!source) | ||
return target; | ||
if (!isObjectOrClass(source)) | ||
if (!isObject(source)) | ||
throw new TypeError('Property "source" requires object type'); | ||
@@ -64,5 +63,5 @@ | ||
let trgVal = target[key]; | ||
if (isObjectOrClass(srcVal)) { | ||
if (isObject(srcVal)) { | ||
if (options.deep) { | ||
if (!isObjectOrClass(trgVal)) { | ||
if (!isObject(trgVal)) { | ||
descriptor.value = trgVal = {}; | ||
@@ -69,0 +68,0 @@ Object.defineProperty(target, key, descriptor); |
{ | ||
"name": "putil-merge", | ||
"description": "Lightweight solution for merging multiple objects into one. Also it supports deep merge and deep clone", | ||
"version": "3.8.0", | ||
"version": "3.9.0", | ||
"author": "Panates Ltd.", | ||
@@ -22,5 +22,7 @@ "contributors": [ | ||
"devDependencies": { | ||
"eslint": "^8.8.0", | ||
"@types/node": "^18.7.23", | ||
"@types/mocha": "^9.1.1", | ||
"eslint": "^8.24.0", | ||
"eslint-config-google": "^0.14.0", | ||
"mocha": "^9.2.0", | ||
"mocha": "^10.0.0", | ||
"nyc": "^15.1.0" | ||
@@ -27,0 +29,0 @@ }, |
10050
6
111