@kizmann/pico-js 0.3.21 → 0.3.24
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/dom.js +5 -1
- package/src/utility/object.js +40 -13
package/package.json
CHANGED
package/src/utility/dom.js
CHANGED
package/src/utility/object.js
CHANGED
@@ -20,7 +20,7 @@ export class Obj
|
|
20
20
|
}
|
21
21
|
|
22
22
|
if ( keys === null || keys === undefined ) {
|
23
|
-
return
|
23
|
+
return fallback;
|
24
24
|
}
|
25
25
|
|
26
26
|
if ( Any.isArray(keys) ) {
|
@@ -35,11 +35,15 @@ export class Obj
|
|
35
35
|
|
36
36
|
let index = 0, length = keys.length;
|
37
37
|
|
38
|
-
|
38
|
+
if ( length === 0 ) {
|
39
|
+
return fallback;
|
40
|
+
}
|
41
|
+
|
42
|
+
while (obj !== undefined && obj !== null && index < length) {
|
39
43
|
obj = obj[keys[index++]];
|
40
44
|
}
|
41
45
|
|
42
|
-
if (
|
46
|
+
if ( obj === undefined || obj === null) {
|
43
47
|
return fallback;
|
44
48
|
}
|
45
49
|
|
@@ -48,26 +52,49 @@ export class Obj
|
|
48
52
|
|
49
53
|
static set(obj, keys, val)
|
50
54
|
{
|
51
|
-
|
52
|
-
keys.
|
55
|
+
if ( Any.isArray(keys) ) {
|
56
|
+
keys = keys.join('.');
|
57
|
+
}
|
53
58
|
|
54
|
-
|
59
|
+
if ( ! Any.isString(keys) ) {
|
60
|
+
keys = keys.toString();
|
61
|
+
}
|
55
62
|
|
56
|
-
|
57
|
-
|
63
|
+
keys = keys.split('.');
|
64
|
+
|
65
|
+
let index = 0, length = keys.length, nested = obj;
|
66
|
+
|
67
|
+
if ( length === 0 ) {
|
68
|
+
return obj;
|
58
69
|
}
|
59
70
|
|
60
|
-
|
61
|
-
|
71
|
+
while (nested !== null && index < length) {
|
72
|
+
|
73
|
+
if ( nested[keys[index]] === undefined || nested[keys[index]] === null ) {
|
74
|
+
nested[keys[index]] = {};
|
75
|
+
}
|
76
|
+
|
77
|
+
if ( index == length - 1 ) {
|
78
|
+
nested[keys[index]] = val;
|
79
|
+
}
|
80
|
+
|
81
|
+
nested = nested[keys[index++]];
|
62
82
|
}
|
63
83
|
|
64
|
-
return
|
84
|
+
return obj;
|
65
85
|
}
|
66
86
|
|
67
87
|
static unset(obj, keys)
|
68
88
|
{
|
69
|
-
|
70
|
-
keys.
|
89
|
+
if ( Any.isArray(keys) ) {
|
90
|
+
keys = keys.join('.');
|
91
|
+
}
|
92
|
+
|
93
|
+
if ( ! Any.isString(keys) ) {
|
94
|
+
keys = keys.toString();
|
95
|
+
}
|
96
|
+
|
97
|
+
keys = keys.split('.');
|
71
98
|
|
72
99
|
let key = keys.shift();
|
73
100
|
|