forked from MapComplete/MapComplete
Cleanup of code
This commit is contained in:
parent
dd91e11bd0
commit
e0f9a93468
12 changed files with 193 additions and 369 deletions
17
Utils.ts
Normal file
17
Utils.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
export class Utils {
|
||||
|
||||
/**
|
||||
* Gives a clean float, or undefined if parsing fails
|
||||
* @param str
|
||||
*/
|
||||
static asFloat(str): number {
|
||||
if (str) {
|
||||
const i = parseFloat(str);
|
||||
if (isNaN(i)) {
|
||||
return undefined;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue