@kizmann/pico-js 0.5.1 → 0.5.3

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.5.1",
3
+ "version": "0.5.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "private": false,
@@ -101,14 +101,56 @@ export class Any
101
101
  return this.isEmpty(val) ? empty : this.string(val);
102
102
  }
103
103
 
104
+ static number(val, fallback = NaN)
105
+ {
106
+ let res = ! val || typeof val.toString === 'undefined' ?
107
+ String(val) : val.toString();
108
+
109
+ if ( ! Any.isString(res) ) {
110
+ return fallback;
111
+ }
112
+
113
+ if ( res.match(/^[0-9]+$/) ) {
114
+ return this.integer(val);
115
+ }
116
+
117
+ if ( res.match(/^[0-9.,]+$/) ) {
118
+ return this.float(val);
119
+ }
120
+
121
+ if ( ! this.isNumber(res) || Number.isNaN(res) ) {
122
+ return fallback;
123
+ }
124
+
125
+ return res;
126
+ }
127
+
104
128
  static integer(val)
105
129
  {
130
+ let res = ! val || typeof val.toString === 'undefined' ?
131
+ String(val) : val.toString();
132
+
133
+ if ( ! Any.isString(res) ) {
134
+ return NaN;
135
+ }
136
+
106
137
  return parseInt(val);
107
138
  }
108
139
 
109
140
  static float(val)
110
141
  {
111
- return parseFloat(val);
142
+ let res = typeof val.toString === 'undefined' ?
143
+ String(val) : val.toString();
144
+
145
+ if ( ! Any.isString(res) ) {
146
+ return NaN;
147
+ }
148
+
149
+ if ( res.match(/^[0-9,]+$/) ) {
150
+ res = res.replace(/,/g, '.');
151
+ }
152
+
153
+ return parseFloat(res);
112
154
  }
113
155
 
114
156
  static bool(val)
package/webservy.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "hostname": "pico-js.local",
3
- "webroot": "/",
4
- "engine": "apache",
3
+ "webroot": "",
4
+ "engine": "httpd",
5
+ "type": "default",
6
+ "proxy": "",
5
7
  "version": "php-8.2.8"
6
8
  }