@neutrium/quantity - v5.0.0
    Preparing search index...

    Class NearleyQtyParser

    Parser for scalar products/division, compound units, powers, and nested groups. Powers bind first, then dot products; * / and whitespace evaluate left to right. Compiled expression plans are shared within a configuration; scalar evaluation follows the original operation order and the current Decimal configuration on every call.

    Index
    • Parse and evaluate a complete scalar/unit expression.

      Parameters

      • input: string

        Expression supporting products, division, powers, groups, scientific notation, and Unicode multiplication/superscript notation.

      • Numeric: ScientificDecimalConstructor = Decimal

        Decimal constructor for evaluation; defaults to the shared Decimal context. Quantity supplies its configured context automatically.

      Returns QuantityDefinition

      A fresh definition with a Decimal scalar and frozen counted units. Unit arrays may be shared with cached plans.

      QuantityParseError for invalid or incomplete syntax, unknown units, invalid exponents, and scalar-evaluation failures.

      Physical checks such as absolute zero belong to Quantity construction.

      import { NearleyQtyParser } from '@neutrium/quantity/parsers/nearley';

      const parsed = new NearleyQtyParser().parse('1/2 m');
      parsed.scalar.toString(); // "0.5"