@incanta/config
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -18,2 +18,3 @@ export interface IConfigOptions { | ||
normalizeString(value: string, currentPath: string[]): string; | ||
normalizeArray(arr: any[], currentPath: string[]): any[]; | ||
normalizeObject(obj: any, currentPath: string[]): any; | ||
@@ -20,0 +21,0 @@ tryGet<T>(key: string): T | null; |
@@ -141,2 +141,21 @@ "use strict"; | ||
} | ||
normalizeArray(arr, currentPath) { | ||
return arr.map((value) => { | ||
if (typeof value === "string") { | ||
return this.normalizeString(value, currentPath); | ||
} | ||
else if (typeof value === "object") { | ||
if (value === null) { | ||
return null; | ||
} | ||
else if (Array.isArray(value)) { | ||
return this.normalizeArray(value, currentPath); | ||
} | ||
else { | ||
return this.normalizeObject(value, currentPath); | ||
} | ||
} | ||
return value; | ||
}); | ||
} | ||
normalizeObject(obj, currentPath) { | ||
@@ -157,3 +176,3 @@ if (typeof obj !== "object" || obj === null) { | ||
else if (Array.isArray(value)) { | ||
continue; | ||
newObj[property] = this.normalizeArray(value, currentPath); | ||
} | ||
@@ -160,0 +179,0 @@ else { |
{ | ||
"name": "@incanta/config", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -204,2 +204,20 @@ import merge from "lodash.merge"; | ||
public normalizeArray(arr: any[], currentPath: string[]): any[] { | ||
return arr.map((value) => { | ||
if (typeof value === "string") { | ||
return this.normalizeString(value, currentPath); | ||
} else if (typeof value === "object") { | ||
if (value === null) { | ||
return null; | ||
} else if (Array.isArray(value)) { | ||
return this.normalizeArray(value, currentPath); | ||
} else { | ||
return this.normalizeObject(value, currentPath); | ||
} | ||
} | ||
return value; | ||
}); | ||
} | ||
public normalizeObject(obj: any, currentPath: string[]): any { | ||
@@ -220,3 +238,3 @@ if (typeof obj !== "object" || obj === null) { | ||
} else if (Array.isArray(value)) { | ||
continue; | ||
newObj[property] = this.normalizeArray(value, currentPath); | ||
} else { | ||
@@ -223,0 +241,0 @@ newObj[property] = this.normalizeObject(value, [ |
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
51809
935