mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-11-04 13:13:55 +01:00
23 lines
434 B
JavaScript
23 lines
434 B
JavaScript
class stringNumber{
|
|
constructor(value,printNaN=true) {
|
|
this.string=value
|
|
this.printNaN=printNaN
|
|
}
|
|
valueOf() {
|
|
return parseFloat(this.string)
|
|
}
|
|
toString(){
|
|
if (checkNumber(this.string) && this.printNaN) {
|
|
return this.string
|
|
} else {
|
|
return NaN.toString()
|
|
}
|
|
}
|
|
}
|
|
function checkNumber(string) {
|
|
try {
|
|
return !Number.isNaN(parseFloat(string))
|
|
} catch (error) {
|
|
return false
|
|
}
|
|
} |