@kizmann/pico-js 0.3.16 → 0.3.19

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.16",
3
+ "version": "0.3.19",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Eduard Kizmann <kizmann@protonmail.ch>",
@@ -91,6 +91,10 @@ export class Num
91
91
 
92
92
  static format(num, decimal = '.', thousand = ',', fixed = null)
93
93
  {
94
+ if ( num === null ) {
95
+ return null;
96
+ }
97
+
94
98
  let value = num.toString();
95
99
 
96
100
  if ( fixed !== null && fixed !== - 1 ) {
@@ -98,7 +102,7 @@ export class Num
98
102
  }
99
103
 
100
104
  let totals = value.replace(/\.[0-9]+$/, ''),
101
- minals = value.replace(/^[0-9]+\./, '');
105
+ minals = value.replace(/^[0-9\-]+\./, '');
102
106
 
103
107
  let splits = Arr.reduce(totals.split('').reverse(), (result, val, key) => {
104
108
 
@@ -26,17 +26,23 @@ 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
+ result = result.concat(key.split('.'))
33
+ });
34
+
35
+ let key = result.shift();
30
36
 
31
37
  if ( typeof obj[key] === 'undefined' ) {
32
38
  return fallback;
33
39
  }
34
40
 
35
- if ( keys.length === 0 ) {
41
+ if ( result.length === 0 ) {
36
42
  return obj[key];
37
43
  }
38
44
 
39
- return this.get(obj[key], keys, fallback)
45
+ return this.get(obj[key], result, fallback);
40
46
  }
41
47
 
42
48
  static set(obj, keys, val)
@@ -86,7 +92,7 @@ export class Obj
86
92
  }
87
93
  });
88
94
 
89
- if ( ! Any.isEmpty(assign) ) {
95
+ if ( !Any.isEmpty(assign) ) {
90
96
  result = this.assign(result, assign);
91
97
  }
92
98
 
@@ -103,7 +109,7 @@ export class Obj
103
109
  }
104
110
  });
105
111
 
106
- if ( ! Any.isEmpty(assign) ) {
112
+ if ( !Any.isEmpty(assign) ) {
107
113
  result = this.assign(result, assign);
108
114
  }
109
115
 
@@ -148,7 +154,7 @@ export class Obj
148
154
  });
149
155
  }
150
156
 
151
- if ( ! Any.isFunction(key) ) {
157
+ if ( !Any.isFunction(key) ) {
152
158
  keys = keys.sort((a, b) => {
153
159
  return Any.integer(Obj.get(obj[a], key)) - Any.integer(Obj.get(obj[b], key));
154
160
  })
@@ -168,13 +174,13 @@ export class Obj
168
174
  {
169
175
  let keys = Any.keys(obj);
170
176
 
171
- if ( ! Any.isFunction(key) ) {
177
+ if ( !Any.isFunction(key) ) {
172
178
  keys = keys.sort((a, b) => {
173
179
 
174
180
  let va = Any.string(Obj.get(obj[a], key)).toLowerCase();
175
181
  let vb = Any.string(Obj.get(obj[b], key)).toLowerCase();
176
182
 
177
- return(va < vb) ? -1 : (va > vb) ? 1 : 0;
183
+ return (va < vb) ? - 1 : (va > vb) ? 1 : 0;
178
184
  })
179
185
  }
180
186
 
@@ -265,8 +271,7 @@ export class Obj
265
271
 
266
272
  if ( obj instanceof FormData ) {
267
273
 
268
- for (let [key, value] of obj.entries())
269
- {
274
+ for ( let [key, value] of obj.entries() ) {
270
275
  result[key] = callback(value, key);
271
276
  }
272
277
 
@@ -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();