@reldens/utils 0.18.0 → 0.18.1
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/lib/shortcuts.js +15 -0
- package/package.json +1 -1
package/lib/shortcuts.js
CHANGED
|
@@ -41,6 +41,9 @@ class Shortcuts
|
|
|
41
41
|
|
|
42
42
|
inArray(value, dataArray)
|
|
43
43
|
{
|
|
44
|
+
if(!this.isArray(dataArray)){
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
44
47
|
return -1 === dataArray.indexOf(value);
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -130,6 +133,18 @@ class Shortcuts
|
|
|
130
133
|
return this.hasOwn(obj, prop) ? obj[prop] : defaultReturn;
|
|
131
134
|
}
|
|
132
135
|
|
|
136
|
+
getByPath(obj, propertyPath, defaultReturn)
|
|
137
|
+
{
|
|
138
|
+
if(!this.isObject(obj) || !this.isArray(propertyPath)){
|
|
139
|
+
return defaultReturn;
|
|
140
|
+
}
|
|
141
|
+
let property = propertyPath.shift();
|
|
142
|
+
if(0 === propertyPath.length){
|
|
143
|
+
return this.get(obj, property, defaultReturn);
|
|
144
|
+
}
|
|
145
|
+
return this.getByPath(obj[property], propertyPath, defaultReturn);
|
|
146
|
+
}
|
|
147
|
+
|
|
133
148
|
getByPriority(obj, propsArray)
|
|
134
149
|
{
|
|
135
150
|
if(!this.isArray(propsArray)){
|