@kizmann/pico-js 0.3.18 → 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 +23 -17
package/package.json
CHANGED
package/src/utility/object.js
CHANGED
@@ -19,24 +19,31 @@ export class Obj
|
|
19
19
|
return fallback;
|
20
20
|
}
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
if ( keys === null || keys === undefined ) {
|
23
|
+
return obj;
|
24
|
+
}
|
24
25
|
|
25
|
-
if ( Any.isArray(keys)
|
26
|
-
keys =
|
26
|
+
if ( Any.isArray(keys) ) {
|
27
|
+
keys = keys.join('.');
|
27
28
|
}
|
28
29
|
|
29
|
-
|
30
|
+
if ( ! Any.isString(keys) ) {
|
31
|
+
keys = keys.toString();
|
32
|
+
}
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
keys = keys.split('.');
|
35
|
+
|
36
|
+
let index = 0, length = keys.length;
|
37
|
+
|
38
|
+
while (obj !== undefined && index < length) {
|
39
|
+
obj = obj[keys[index++]];
|
33
40
|
}
|
34
41
|
|
35
|
-
if (
|
36
|
-
return
|
42
|
+
if ( typeof obj === 'undefined' ) {
|
43
|
+
return fallback;
|
37
44
|
}
|
38
45
|
|
39
|
-
return
|
46
|
+
return obj;
|
40
47
|
}
|
41
48
|
|
42
49
|
static set(obj, keys, val)
|
@@ -86,7 +93,7 @@ export class Obj
|
|
86
93
|
}
|
87
94
|
});
|
88
95
|
|
89
|
-
if ( !
|
96
|
+
if ( !Any.isEmpty(assign) ) {
|
90
97
|
result = this.assign(result, assign);
|
91
98
|
}
|
92
99
|
|
@@ -103,7 +110,7 @@ export class Obj
|
|
103
110
|
}
|
104
111
|
});
|
105
112
|
|
106
|
-
if ( !
|
113
|
+
if ( !Any.isEmpty(assign) ) {
|
107
114
|
result = this.assign(result, assign);
|
108
115
|
}
|
109
116
|
|
@@ -148,7 +155,7 @@ export class Obj
|
|
148
155
|
});
|
149
156
|
}
|
150
157
|
|
151
|
-
if ( !
|
158
|
+
if ( !Any.isFunction(key) ) {
|
152
159
|
keys = keys.sort((a, b) => {
|
153
160
|
return Any.integer(Obj.get(obj[a], key)) - Any.integer(Obj.get(obj[b], key));
|
154
161
|
})
|
@@ -168,13 +175,13 @@ export class Obj
|
|
168
175
|
{
|
169
176
|
let keys = Any.keys(obj);
|
170
177
|
|
171
|
-
if ( !
|
178
|
+
if ( !Any.isFunction(key) ) {
|
172
179
|
keys = keys.sort((a, b) => {
|
173
180
|
|
174
181
|
let va = Any.string(Obj.get(obj[a], key)).toLowerCase();
|
175
182
|
let vb = Any.string(Obj.get(obj[b], key)).toLowerCase();
|
176
183
|
|
177
|
-
return(va < vb) ? -1 : (va > vb) ? 1 : 0;
|
184
|
+
return (va < vb) ? - 1 : (va > vb) ? 1 : 0;
|
178
185
|
})
|
179
186
|
}
|
180
187
|
|
@@ -265,8 +272,7 @@ export class Obj
|
|
265
272
|
|
266
273
|
if ( obj instanceof FormData ) {
|
267
274
|
|
268
|
-
for (let [key, value] of obj.entries())
|
269
|
-
{
|
275
|
+
for ( let [key, value] of obj.entries() ) {
|
270
276
|
result[key] = callback(value, key);
|
271
277
|
}
|
272
278
|
|