@homer0/deep-assign
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -21,3 +21,6 @@ // src/deepAssign.ts | ||
} | ||
return targets.filter((target) => this.isValidItem(target)).reduce((acc, target) => acc === null ? this.resolveFromEmpty(target, true) : this.resolve(acc, target, true), null); | ||
return targets.filter((target) => this.isValidItem(target)).reduce( | ||
(acc, target) => acc === null ? this.resolveFromEmpty(target, true) : this.resolve(acc, target, true), | ||
null | ||
); | ||
} | ||
@@ -33,3 +36,5 @@ isPlainObject(target) { | ||
if (mode === "concat") { | ||
result = [...source, ...target].map((targetItem) => this.resolveFromEmpty(targetItem)); | ||
result = [...source, ...target].map( | ||
(targetItem) => this.resolveFromEmpty(targetItem) | ||
); | ||
} else if (mode === "overwrite") { | ||
@@ -63,6 +68,9 @@ result = target.slice().map((targetItem) => this.resolveFromEmpty(targetItem)); | ||
const keys = [...Object.getOwnPropertySymbols(useTarget), ...Object.keys(useTarget)]; | ||
const subMerge = keys.reduce((acc, key) => ({ | ||
...acc, | ||
[key]: this.resolve(useSource[key], useTarget[key]) | ||
}), {}); | ||
const subMerge = keys.reduce( | ||
(acc, key) => ({ | ||
...acc, | ||
[key]: this.resolve(useSource[key], useTarget[key]) | ||
}), | ||
{} | ||
); | ||
return { ...useSource, ...useTarget, ...subMerge }; | ||
@@ -69,0 +77,0 @@ } |
@@ -50,3 +50,6 @@ "use strict"; | ||
} | ||
return targets.filter((target) => this.isValidItem(target)).reduce((acc, target) => acc === null ? this.resolveFromEmpty(target, true) : this.resolve(acc, target, true), null); | ||
return targets.filter((target) => this.isValidItem(target)).reduce( | ||
(acc, target) => acc === null ? this.resolveFromEmpty(target, true) : this.resolve(acc, target, true), | ||
null | ||
); | ||
} | ||
@@ -62,3 +65,5 @@ isPlainObject(target) { | ||
if (mode === "concat") { | ||
result = [...source, ...target].map((targetItem) => this.resolveFromEmpty(targetItem)); | ||
result = [...source, ...target].map( | ||
(targetItem) => this.resolveFromEmpty(targetItem) | ||
); | ||
} else if (mode === "overwrite") { | ||
@@ -92,6 +97,9 @@ result = target.slice().map((targetItem) => this.resolveFromEmpty(targetItem)); | ||
const keys = [...Object.getOwnPropertySymbols(useTarget), ...Object.keys(useTarget)]; | ||
const subMerge = keys.reduce((acc, key) => ({ | ||
...acc, | ||
[key]: this.resolve(useSource[key], useTarget[key]) | ||
}), {}); | ||
const subMerge = keys.reduce( | ||
(acc, key) => ({ | ||
...acc, | ||
[key]: this.resolve(useSource[key], useTarget[key]) | ||
}), | ||
{} | ||
); | ||
return { ...useSource, ...useTarget, ...subMerge }; | ||
@@ -98,0 +106,0 @@ } |
{ | ||
"name": "@homer0/deep-assign", | ||
"description": "Deep merge (and copy) of objects and Arrays using native spread syntax", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"repository": { | ||
@@ -26,6 +26,6 @@ "type": "git", | ||
"devDependencies": { | ||
"jest": "^28.1.2", | ||
"ts-jest": "^28.0.5", | ||
"tsup": "^6.1.3", | ||
"typescript": "^4.7.4" | ||
"jest": "^29.2.1", | ||
"ts-jest": "^29.0.3", | ||
"tsup": "^6.3.0", | ||
"typescript": "^4.8.4" | ||
}, | ||
@@ -40,2 +40,3 @@ "engine-strict": true, | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "jest -c ./.jestrc.js", | ||
@@ -46,3 +47,3 @@ "types:check": "tsc --noEmit && tsc --noEmit --project ./tests/tsconfig.json", | ||
}, | ||
"gitHead": "7c44773961f29d11890564831e84cf4da9ba0f57" | ||
"gitHead": "e584e4ef93ede1065a91a1d3e88e070662acb66e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
40668
279