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

    Class RegexQtyParser

    Legacy parser for scalar and unit expressions without parenthesized grouping. Powers bind first, then dot products; * / and whitespace evaluate from left to right.

    Import from @neutrium/quantity/parsers.js. Pass an instance as the third argument to Quantity constructor, or call parse directly when a parsed definition is needed.

    import { Quantity } from '@neutrium/quantity';
    import { RegexQtyParser } from '@neutrium/quantity/parsers.js';

    const parser = new RegexQtyParser();
    const force = new Quantity('2 kg*m/s^2', undefined, parser);
    force.to('N').scalar.toString(); // "2"

    Implements

    Index
    • Parse a scalar and counted units without expanding powers.

      Parameters

      • val: string

        Expression such as "2 kg*m/s^2", "m", or "2".

      • Numeric: ScientificDecimalConstructor = Decimal

        Decimal constructor used to evaluate the scalar; defaults to shared Decimal.

      Returns QuantityDefinition

      A definition accepted by Quantity. Empty sides represent unity.

      If syntax, unit tokens, or integer exponents are invalid.