@reldens/utils 0.17.8 → 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.
Files changed (2) hide show
  1. package/lib/shortcuts.js +22 -2
  2. package/package.json +1 -1
package/lib/shortcuts.js CHANGED
@@ -41,12 +41,20 @@ 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
 
47
- isFunction(obj, property)
50
+ isFunction(callback)
51
+ {
52
+ return callback && 'function' === typeof callback;
53
+ }
54
+
55
+ isObjectFunction(obj, property)
48
56
  {
49
- return 'function' === typeof obj[property];
57
+ return this.isObject(obj) && property && 'function' === typeof obj[property];
50
58
  }
51
59
 
52
60
  deepMergeProperties(target, source)
@@ -125,6 +133,18 @@ class Shortcuts
125
133
  return this.hasOwn(obj, prop) ? obj[prop] : defaultReturn;
126
134
  }
127
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
+
128
148
  getByPriority(obj, propsArray)
129
149
  {
130
150
  if(!this.isArray(propsArray)){
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reldens/utils",
3
3
  "scope": "@reldens",
4
- "version": "0.17.8",
4
+ "version": "0.18.1",
5
5
  "description": "Reldens - Utils",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",