👁️🗨️ Parsers without nonsense.
Instead of throwing or returning values like NaN
, the parsers in this library
either return the expected parsed value or undefined
(making use of the
Maybe type).
Install @vangware/parsers
as a dependency:
pnpm add @vangware/parsers
# or
npm install @vangware/parsers
# or
yarn add @vangware/parsers
Import it and use it:
import { parseDecimal } from "@vangware/parsers";
parseDecimal("101"); // 101
parseDecimal("nope"); // undefined
Import @vangware/parsers
using the npm:
prefix, and use it directly:
import { parseDecimal } from "npm:@vangware/parsers";
parseDecimal("101"); // 101
parseDecimal("nope"); // undefined
Import @vangware/parsers
using esm.sh, and use it directly:
<script type="module">
import { parseDecimal } from "https://esm.sh/@vangware/parsers";
parseDecimal("101"); // 101
parseDecimal("nope"); // undefined
</script>