(s: string)
| 719 | * @since 2.0.0 |
| 720 | */ |
| 721 | export const parse = (s: string): Option.Option<number> => { |
| 722 | if (s === "NaN") { |
| 723 | return Option.some(NaN) |
| 724 | } |
| 725 | if (s === "Infinity") { |
| 726 | return Option.some(Infinity) |
| 727 | } |
| 728 | if (s === "-Infinity") { |
| 729 | return Option.some(-Infinity) |
| 730 | } |
| 731 | if (s.trim() === "") { |
| 732 | return Option.none() |
| 733 | } |
| 734 | const n = Number(s) |
| 735 | return Number.isNaN(n) ? Option.none() : Option.some(n) |
| 736 | } |
| 737 | |
| 738 | /** |
| 739 | * Returns the number rounded with the given precision. |