@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizmann/pico-js",
3
- "version": "0.3.17",
3
+ "version": "0.3.20",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Eduard Kizmann <kizmann@protonmail.ch>",
@@ -26,17 +26,31 @@ export class Obj
26
26
  keys = [keys];
27
27
  }
28
28
 
29
- let key = keys.shift();
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 ( keys.length === 0 ) {
49
+ if ( result.length === 0 ) {
36
50
  return obj[key];
37
51
  }
38
52
 
39
- return this.get(obj[key], keys, fallback)
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 ( ! Any.isEmpty(assign) ) {
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 ( ! Any.isEmpty(assign) ) {
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 ( ! Any.isFunction(key) ) {
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 ( ! Any.isFunction(key) ) {
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
 
@@ -10,6 +10,11 @@ export class Str
10
10
  return String(val).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
11
11
  }
12
12
 
13
+ static upper(val)
14
+ {
15
+ return String(val).toUpperCase();
16
+ }
17
+
13
18
  static lower(val)
14
19
  {
15
20
  return String(val).toLowerCase();