@ctx-core/object
Advanced tools
Comparing version 4.1.1 to 4.2.0
26
lib.js
@@ -117,2 +117,26 @@ import { _andand } from '@ctx-core/function' | ||
/** | ||
* Performs a deep merge on the target with each a1__source | ||
* @param target | ||
* @param {...object} a1__source | ||
* @returns target | ||
*/ | ||
export function merge(target, ...a1__source) { | ||
// Loop through each object and conduct a merge | ||
for (let i = 0; i < a1__source.length; i++) { | ||
const source = a1__source[i] | ||
for (let prop in source) { | ||
if (source.hasOwnProperty(prop)) { | ||
if (Object.prototype.toString.call(source[prop]) === '[object Object]') { | ||
// If we're doing a deep merge and the property is an object | ||
target[prop] = merge(target[prop], source[prop]) | ||
} else { | ||
// Otherwise, do a regular merge | ||
target[prop] = source[prop] | ||
} | ||
} | ||
} | ||
} | ||
return target | ||
} | ||
/** | ||
* Ensures that the keys in `a1__rest` are added to ctx | ||
@@ -183,3 +207,3 @@ * only if the key is not defined on [ctx](#ctx) (== null). | ||
export function unpick__keys(ctx, obj__keys) { | ||
return unpick(ctx, ...Object.keys(obj__keys)) | ||
return unpick(ctx, ...Object.keys(obj__keys)) | ||
} | ||
@@ -186,0 +210,0 @@ export function _a1__value__pick(ctx, ...a1__key) { |
{ | ||
"name": "@ctx-core/object", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "ctx-core object", | ||
@@ -26,3 +26,3 @@ "main": "lib.js", | ||
}, | ||
"gitHead": "a5ae765cd901bed2ae71125bf82671731709c5fd" | ||
"gitHead": "5229bb0b2a18a268f80352a7f49ea2b6b4047bbe" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12169
428