parser-ts
parser-ts copied to clipboard
Add hexDigit combinator
🚀 Feature request
Current Behavior
Currently there is no hexadecimal digit combinator available in parser-ts/char.
Desired Behavior
The "core" library export a hexDigit combinator since it's quite common e.g. Haskell and Purescript
Suggested Solution
const isHexDigit: (c: Char) => boolean = (c) =>
"0123456789abcdef".indexOf(c.toLowerCase()) !== -1;
const hexDigit: P.Parser<Char, Char> = P.expected(P.sat(isHexDigit), "a hex digit");
Who does this impact? Who is this for?
All users, regardless of skill would benefit from this. Not dependant on TS version.
Describe alternatives you've considered
It's easy enough to build this yourself and put into your own codebase. I've done so while attempting to port over my own uuid and mac address parsers written in Purescript.
Additional context
Your environment
| Software | Version(s) |
|---|---|
| fp-ts | 2.16.1 |
| parser-ts | 0.7.0 |
| TypeScript | 5.2.2 |