til

today i learned

View on GitHub

A Better Number() and Number.parseFloat()

const numberSafeParse = (input: string): number | null => {
    if (input.trim() === "") return null;
    let parsed = Number(input);
    if (!Number.isFinite(parsed)) return null;
    return parsed;
};

source