yummies/parser
Description
Parsers for user-entered numbers, percents, and strings with tolerant input and typed results. Use when normalizing form values, query params, or CSV-like text before validation schemas run, without duplicating regex and parseFloat edge cases in every feature module.
Usage
import { parser } from "yummies/parser";parser.NumberParserSettings
No description.
parser.number()
Parses a number from raw input and optionally clamps, rounds or limits fractional digits.
Strings are normalized by removing spaces and replacing , with . before parsing. Invalid inputs return the configured fallback.
Examples:
number('1 234,5'); // 1234.5number('bad', { fallback: 0 }); // 0parser.percent()
Converts a value into a percentage of maxValue and parses the result with the shared numeric parser.
Examples:
percent(25, 200); // 12.5percent('bad', 100, { fallback: 0 }); // 0parser.StringParserSettings
No description.
parser.string()
Converts arbitrary input into a string representation.
Objects are serialized with JSON.stringify, optionally pretty-printed, and nullish values resolve to the configured fallback.
Examples:
string(123); // '123'string({ id: 1 }, { prettyJson: true });