@kizmann/pico-js 0.3.20 → 0.3.21
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/pico-js.js +1 -1
- package/dist/pico-js.js.map +1 -1
- package/package.json +1 -1
- package/src/utility/object.js +15 -22
package/package.json
CHANGED
package/src/utility/object.js
CHANGED
@@ -19,38 +19,31 @@ export class Obj
|
|
19
19
|
return fallback;
|
20
20
|
}
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
if ( Any.isArray(keys) === false ) {
|
26
|
-
keys = [keys];
|
22
|
+
if ( keys === null || keys === undefined ) {
|
23
|
+
return obj;
|
27
24
|
}
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
30
|
+
if ( ! Any.isString(keys) ) {
|
31
|
+
keys = keys.toString();
|
32
|
+
}
|
39
33
|
|
40
|
-
|
41
|
-
});
|
34
|
+
keys = keys.split('.');
|
42
35
|
|
43
|
-
let
|
36
|
+
let index = 0, length = keys.length;
|
44
37
|
|
45
|
-
|
46
|
-
|
38
|
+
while (obj !== undefined && index < length) {
|
39
|
+
obj = obj[keys[index++]];
|
47
40
|
}
|
48
41
|
|
49
|
-
if (
|
50
|
-
return
|
42
|
+
if ( typeof obj === 'undefined' ) {
|
43
|
+
return fallback;
|
51
44
|
}
|
52
45
|
|
53
|
-
return
|
46
|
+
return obj;
|
54
47
|
}
|
55
48
|
|
56
49
|
static set(obj, keys, val)
|