@neutrium/formatter - v1.0.1
    Preparing search index...

    Interface CompiledParser<Value, Spec>

    Reusable parser returned by extensions-parse!Parser.compile.

    The specification and resolution are deeply frozen. The bound parse method can be passed directly to Array.map; it always exists after compilation succeeds.

    import { parser } from "@neutrium/formatter/parse";

    const money = parser.compile({ kind: "currency", currency: "USD" });
    ["$12.25", "$20.00"].map(money.parse); // ["12.25", "20"]
    interface CompiledParser<
        Value = unknown,
        Spec extends FormatSpecBase = FormatSpecBase,
    > {
        resolution: SupportedResolvedFormat;
        spec: { kind: string; locale: string };
        parse(input: string): Value;
    }

    Type Parameters

    • Value = unknown

      Parsed result; built-in parsers return canonical strings.

    • Spec extends FormatSpecBase = FormatSpecBase

      Bound specification type.

    Index
    resolution: SupportedResolvedFormat

    Successful, cached parsing resolution; rendering capabilities are false.

    spec: { kind: string; locale: string }

    Deeply copied and frozen specification, including its effective locale.

    Type Declaration

    • Readonlykind: string

      Literal discriminator used to select a registered codec.

    • Readonlylocale: string

      Explicit specification locale or the default captured during compilation.

    • Parses text using the bound locale and specification; invalid input throws.

      Parameters

      • input: string

        Complete localized presentation to parse.

      Returns Value

      The parser codec's domain value.

      import { parser } from "@neutrium/formatter/parse";
      const percent = parser.compile({ kind: "percentage", maximumFractionDigits: 1 });
      percent.parse("12.5%"); // "0.125"