Adapter instance, parser factory, and optional Quantity configuration.
The parser factory receives resolved parser-cache settings. Its parser must evaluate
scalars with the adapter supplied to parse; wrappers should forward its cache scope and optional replacement scalar.
Optionalconfig?: QuantityConfigInput<NoInfer<NumericOptions<A>>>Optional numeric overrides and Quantity cache policies, using the withConfig shape.
Immutable backend instance used for this class's scalar representation and arithmetic.
Create a parser from the resolved Quantity parser-cache settings.
A class whose instances, clones and calculated results retain this configuration.
TypeError for unknown options, an invalid parser factory, or an adapter missing the arithmetic capabilities required by Quantity.
import { createQuantityClass } from '@neutrium/quantity/factory';
import { RegexParser } from '@neutrium/quantity/parsers/regex';
import { NumberAdapter } from '@neutrium/math/adapters/number';
const NativeQuantity = createQuantityClass({
numeric: new NumberAdapter(),
parser: config => new RegexParser(config),
config: { cache: false },
});
new NativeQuantity('2 km').to('m').scalar; // 2000
Create a Quantity class with a chosen numeric backend and parser.