21 lines
357 B
TypeScript
21 lines
357 B
TypeScript
|
|
// Helpers...
|
|
export function parseDouble(text: string): number | undefined {
|
|
if (text === '') {
|
|
return;
|
|
}
|
|
const num = Number(text);
|
|
if (Number.isNaN(num)) {
|
|
return;
|
|
}
|
|
return num;
|
|
}
|
|
export function parseInt(text: string): bigint | undefined {
|
|
if (text === '') {
|
|
return;
|
|
}
|
|
try {
|
|
return BigInt(text);
|
|
}
|
|
catch (e) { };
|
|
}
|