@contrail/util 1.1.3-alpha.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,7 +15,7 @@ class ObjectUtil {
|
|
|
15
15
|
return value === undefined ? def : value;
|
|
16
16
|
}
|
|
17
17
|
const pathUnits = path.split('.');
|
|
18
|
-
pathUnits.forEach(level => {
|
|
18
|
+
pathUnits.forEach((level) => {
|
|
19
19
|
if (obj) {
|
|
20
20
|
obj = obj[level];
|
|
21
21
|
}
|
|
@@ -59,11 +59,11 @@ class ObjectUtil {
|
|
|
59
59
|
if (data === null || data === undefined || typeof data !== 'object') {
|
|
60
60
|
return data;
|
|
61
61
|
}
|
|
62
|
-
const isEmpty = (
|
|
62
|
+
const isEmpty = (value) => value === null || value === undefined || (typeof value === 'string' && value.trim() === '');
|
|
63
63
|
if (Array.isArray(data)) {
|
|
64
64
|
const cleaned = data
|
|
65
|
-
.map(item => (typeof item === 'object' && item ? ObjectUtil.removeEmptyProperties(item) : item))
|
|
66
|
-
.filter(item => !isEmpty(item));
|
|
65
|
+
.map((item) => (typeof item === 'object' && item ? ObjectUtil.removeEmptyProperties(item) : item))
|
|
66
|
+
.filter((item) => !isEmpty(item));
|
|
67
67
|
return cleaned;
|
|
68
68
|
}
|
|
69
69
|
const cleaned = Object.entries(data).reduce((acc, [key, value]) => {
|