@kizmann/pico-js 0.3.20 → 0.3.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizmann/pico-js",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Eduard Kizmann <kizmann@protonmail.ch>",
@@ -19,38 +19,31 @@ export class Obj
19
19
  return fallback;
20
20
  }
21
21
 
22
- keys = (typeof keys === 'string' && keys.match(/^[^\.]+(\.[^\.]+)*$/)) ?
23
- keys.split('.') : keys;
24
-
25
- if ( Any.isArray(keys) === false ) {
26
- keys = [keys];
22
+ if ( keys === null || keys === undefined ) {
23
+ return obj;
27
24
  }
28
25
 
29
- let result = [];
30
-
31
- Arr.each(keys, (key) => {
32
-
33
- key = (typeof key === 'string' && key.match(/^[^\.]+(\.[^\.]+)*$/)) ?
34
- key.split('.') : key;
26
+ if ( Any.isArray(keys) ) {
27
+ keys = keys.join('.');
28
+ }
35
29
 
36
- if ( Any.isArray(keys) === false ) {
37
- key = [key];
38
- }
30
+ if ( ! Any.isString(keys) ) {
31
+ keys = keys.toString();
32
+ }
39
33
 
40
- result = result.concat(key)
41
- });
34
+ keys = keys.split('.');
42
35
 
43
- let key = result.shift();
36
+ let index = 0, length = keys.length;
44
37
 
45
- if ( typeof obj[key] === 'undefined' ) {
46
- return fallback;
38
+ while (obj !== undefined && index < length) {
39
+ obj = obj[keys[index++]];
47
40
  }
48
41
 
49
- if ( result.length === 0 ) {
50
- return obj[key];
42
+ if ( typeof obj === 'undefined' ) {
43
+ return fallback;
51
44
  }
52
45
 
53
- return this.get(obj[key], result, fallback);
46
+ return obj;
54
47
  }
55
48
 
56
49
  static set(obj, keys, val)