appolo-utils
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -13,2 +13,11 @@ "use strict"; | ||
} | ||
static closeDeep(obj) { | ||
let output = Array.isArray(obj) ? [] : {}; | ||
let keys = Object.keys(obj); | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
let key = keys[i], value = obj[key]; | ||
output[key] = (value == null || typeof value != "object") ? value : Objects.closeDeep(value); | ||
} | ||
return output; | ||
} | ||
static compact(obj) { | ||
@@ -15,0 +24,0 @@ let output = {}; |
@@ -10,6 +10,21 @@ export class Objects { | ||
public static cloneFast(obj: any): any { | ||
public static cloneFast<T>(obj: T): T { | ||
return JSON.parse(JSON.stringify(obj)) | ||
} | ||
public static closeDeep<T>(obj: T): T { | ||
let output = Array.isArray(obj) ? [] : {}; | ||
let keys = Object.keys(obj); | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
let key = keys[i],value = obj[key]; | ||
output[key] = (value == null || typeof value != "object") ?value : Objects.closeDeep(value) | ||
} | ||
return output as any; | ||
} | ||
public static compact(obj: any): any { | ||
@@ -16,0 +31,0 @@ |
@@ -17,3 +17,3 @@ { | ||
"main": "./index.js", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"license": "MIT", | ||
@@ -20,0 +20,0 @@ "repository": { |
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
52130
985