Comparing version 1.10.0 to 1.10.1
@@ -157,21 +157,31 @@ "use strict"; | ||
const target = {}; | ||
for (const key of Object.keys(source).sort()) { | ||
if (source[key] === null) { | ||
target[key] = null; | ||
if (source === null) { | ||
return null; | ||
} | ||
else if (Array.isArray(source)) { | ||
const propertyKey = this.getKeyProperty(source[0]); | ||
if (propertyKey) { | ||
const result = source.map((p) => this.sort(p)).sort((a, b) => a[propertyKey] > b[propertyKey] ? 1 : -1); | ||
return result; | ||
} | ||
else if (Array.isArray(source[key])) { | ||
const propertyKey = this.getKeyProperty(source[key]); | ||
if (propertyKey) { | ||
target[key] = source[key].sort((a, b) => a[propertyKey] > b[propertyKey] ? 1 : -1).map((p) => this.sort(p)); | ||
else { | ||
const result = source.map((p) => this.sort(p)).sort((a, b) => JSON.stringify(a) > JSON.stringify(b) ? 1 : -1); | ||
return result; | ||
} | ||
} | ||
else if (typeof source === 'object') { | ||
for (const key of Object.keys(source).sort()) { | ||
if (source[key] === null) { | ||
target[key] = null; | ||
} | ||
else if (Array.isArray(source[key])) { | ||
target[key] = this.sort(source[key]); | ||
} | ||
else if (typeof source[key] === 'object') { | ||
target[key] = this.sort(source[key]); | ||
} | ||
else { | ||
target[key] = source[key].map((p) => this.sort(p)); | ||
target[key] = source[key]; | ||
} | ||
} | ||
else if (typeof source[key] === 'object') { | ||
target[key] = this.sort(source[key]); | ||
} | ||
else { | ||
target[key] = source[key]; | ||
} | ||
} | ||
@@ -178,0 +188,0 @@ return target; |
{ | ||
"name": "h3lp", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "Helper for nodeJs", | ||
@@ -5,0 +5,0 @@ "author": "Flavio Lionel Rita <flaviolrita@hotmail.com>", |
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
227362
2937