10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-07-04 02:16:11 +02:00
QUESTDB_website/static/js/floatUtils.js

25 lines
404 B
JavaScript
Raw Normal View History

class stringFloat{
constructor(value) {
this.string=value
}
get Value(){
return parseFloat(this.string)
}
valueOf() {
return this.Value;
}
toString(){
2020-02-01 17:24:58 +01:00
if (checkFloat(this.string)) {
return this.Value
} else {
return this.string
}
}
}
function checkFloat(string) {
try {
2020-02-01 17:19:40 +01:00
return !isNaN(parseFloat(string))
} catch (error) {
return false
}
}