@mongez/reinforcements 2.0.9 → 2.0.10
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.
- package/cjs/object/get.js +2 -2
- package/esm/object/get.js +2 -2
- package/package.json +1 -1
package/cjs/object/get.js
CHANGED
|
@@ -5,10 +5,10 @@ function getValue(object, keyChain, defaultValue) {
|
|
|
5
5
|
// then loop through the array and get the value of each key until the last key
|
|
6
6
|
// then return the value of the last key
|
|
7
7
|
return keyChain.split(".").reduce(function (acc, key) {
|
|
8
|
-
if (acc === undefined) {
|
|
8
|
+
if (acc === undefined || typeof acc !== "object") {
|
|
9
9
|
return defaultValue;
|
|
10
10
|
}
|
|
11
|
-
return
|
|
11
|
+
return key in acc ? acc[key] : defaultValue;
|
|
12
12
|
}, object);
|
|
13
13
|
}
|
|
14
14
|
/**
|
package/esm/object/get.js
CHANGED
|
@@ -3,10 +3,10 @@ function getValue(object, keyChain, defaultValue) {
|
|
|
3
3
|
// then loop through the array and get the value of each key until the last key
|
|
4
4
|
// then return the value of the last key
|
|
5
5
|
return keyChain.split(".").reduce(function (acc, key) {
|
|
6
|
-
if (acc === undefined) {
|
|
6
|
+
if (acc === undefined || typeof acc !== "object") {
|
|
7
7
|
return defaultValue;
|
|
8
8
|
}
|
|
9
|
-
return
|
|
9
|
+
return key in acc ? acc[key] : defaultValue;
|
|
10
10
|
}, object);
|
|
11
11
|
}
|
|
12
12
|
/**
|
package/package.json
CHANGED