Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92f36fdb5b | |||
| 721fe2dcf8 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.30.6",
|
||||
"version": "0.30.7",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -97,8 +97,10 @@ export function deepCopy<T>(value: T): T {
|
||||
* @return {any} The des
|
||||
*/
|
||||
export function deepMerge<T>(target: any, ...sources: any[]): T {
|
||||
const BLOCKED = new Set(['__proto__', 'constructor', 'prototype']);
|
||||
sources.forEach(s => {
|
||||
for(const key in s) {
|
||||
if(BLOCKED.has(key) || !Object.prototype.hasOwnProperty.call(s, key)) continue;
|
||||
if(s[key] && typeof s[key] == 'object' && !Array.isArray(s[key])) {
|
||||
if(!target[key]) target[key] = {};
|
||||
deepMerge(target[key], s[key]);
|
||||
|
||||
Reference in New Issue
Block a user