@neutrium/quantity - v7.1.0
    Preparing search index...

    Interface NumericQuantityConstructor<T, Options, Resolved>

    A constructible Quantity class bound to one numeric backend and parser factory. Returned by createQuantityClass and used by the package presets. The scalar type and available numeric configuration are inferred from the adapter.

    interface NumericQuantityConstructor<
        T,
        Options = never,
        Resolved extends object = object,
    > {
        new NumericQuantityConstructor(
            input: QuantityInput<T>,
            units?: string,
            parser?: Parser<T>,
        ): Quantity<T, Resolved>;
        config: QuantityConfig<Resolved>;
        conversionCacheConfig: CacheConfig;
        parserConfig: ParserConfig;
        withConfig<C extends new (...args: never[]) => Quantity<any>>(
            this: C,
            options: QuantityConfigInput<Options>,
        ): C;
    }

    Type Parameters

    • T
    • Options = never
    • Resolved extends object = object
    Index
    • Construct from an expression, scalar with optional units, definition, or Quantity. An existing Quantity preserves its units and converts to this class's backend; a plain definition must already contain a destination-native scalar.

      Parameters

      • input: QuantityInput<T>

        Value or expression to construct.

      • Optionalunits: string

        Units for a separate scalar; ignored for quantities and definitions.

      • Optionalparser: Parser<T>

        Optional override retained by derived operations and clones.

      Returns Quantity<T, Resolved>

      For invalid syntax, units, scalar representations or absolute temperatures.

      import { Quantity } from '@neutrium/quantity';
      import { Quantity as NumberQuantity } from '@neutrium/quantity/number';
      const native = new NumberQuantity('1.25 m');
      const decimal = new Quantity(native);
      decimal.to('cm').scalar.toString(); // "125"

    Complete effective numeric and cache configuration.

    conversionCacheConfig: CacheConfig

    Per-instance conversion cache limits.

    parserConfig: ParserConfig

    Effective parser configuration.

    • Create a class with numeric overrides and Quantity cache policies. Omitted settings inherit; cache: false disables optional caching and true restores defaults. Numeric overrides require a configurable adapter. The original class is unchanged; results retain the newly configured class.

      Type Parameters

      • C extends new (...args: never[]) => Quantity<any>

      Parameters

      Returns C

      import { Quantity } from '@neutrium/quantity';
      const Uncached = Quantity.withConfig({ cache: false });
      new Uncached('2 m').config === Uncached.config; // true