@kizmann/pico-js 0.3.17 → 0.3.20
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 -10
- package/src/utility/string.js +5 -0
package/package.json
CHANGED
package/src/utility/object.js
CHANGED
@@ -26,17 +26,31 @@ export class Obj
|
|
26
26
|
keys = [keys];
|
27
27
|
}
|
28
28
|
|
29
|
-
let
|
29
|
+
let result = [];
|
30
|
+
|
31
|
+
Arr.each(keys, (key) => {
|
32
|
+
|
33
|
+
key = (typeof key === 'string' && key.match(/^[^\.]+(\.[^\.]+)*$/)) ?
|
34
|
+
key.split('.') : key;
|
35
|
+
|
36
|
+
if ( Any.isArray(keys) === false ) {
|
37
|
+
key = [key];
|
38
|
+
}
|
39
|
+
|
40
|
+
result = result.concat(key)
|
41
|
+
});
|
42
|
+
|
43
|
+
let key = result.shift();
|
30
44
|
|
31
45
|
if ( typeof obj[key] === 'undefined' ) {
|
32
46
|
return fallback;
|
33
47
|
}
|
34
48
|
|
35
|
-
if (
|
49
|
+
if ( result.length === 0 ) {
|
36
50
|
return obj[key];
|
37
51
|
}
|
38
52
|
|
39
|
-
return this.get(obj[key],
|
53
|
+
return this.get(obj[key], result, fallback);
|
40
54
|
}
|
41
55
|
|
42
56
|
static set(obj, keys, val)
|
@@ -86,7 +100,7 @@ export class Obj
|
|
86
100
|
}
|
87
101
|
});
|
88
102
|
|
89
|
-
if ( !
|
103
|
+
if ( !Any.isEmpty(assign) ) {
|
90
104
|
result = this.assign(result, assign);
|
91
105
|
}
|
92
106
|
|
@@ -103,7 +117,7 @@ export class Obj
|
|
103
117
|
}
|
104
118
|
});
|
105
119
|
|
106
|
-
if ( !
|
120
|
+
if ( !Any.isEmpty(assign) ) {
|
107
121
|
result = this.assign(result, assign);
|
108
122
|
}
|
109
123
|
|
@@ -148,7 +162,7 @@ export class Obj
|
|
148
162
|
});
|
149
163
|
}
|
150
164
|
|
151
|
-
if ( !
|
165
|
+
if ( !Any.isFunction(key) ) {
|
152
166
|
keys = keys.sort((a, b) => {
|
153
167
|
return Any.integer(Obj.get(obj[a], key)) - Any.integer(Obj.get(obj[b], key));
|
154
168
|
})
|
@@ -168,13 +182,13 @@ export class Obj
|
|
168
182
|
{
|
169
183
|
let keys = Any.keys(obj);
|
170
184
|
|
171
|
-
if ( !
|
185
|
+
if ( !Any.isFunction(key) ) {
|
172
186
|
keys = keys.sort((a, b) => {
|
173
187
|
|
174
188
|
let va = Any.string(Obj.get(obj[a], key)).toLowerCase();
|
175
189
|
let vb = Any.string(Obj.get(obj[b], key)).toLowerCase();
|
176
190
|
|
177
|
-
return(va < vb) ? -1 : (va > vb) ? 1 : 0;
|
191
|
+
return (va < vb) ? - 1 : (va > vb) ? 1 : 0;
|
178
192
|
})
|
179
193
|
}
|
180
194
|
|
@@ -265,8 +279,7 @@ export class Obj
|
|
265
279
|
|
266
280
|
if ( obj instanceof FormData ) {
|
267
281
|
|
268
|
-
for (let [key, value] of obj.entries())
|
269
|
-
{
|
282
|
+
for ( let [key, value] of obj.entries() ) {
|
270
283
|
result[key] = callback(value, key);
|
271
284
|
}
|
272
285
|
|
package/src/utility/string.js
CHANGED