Skip to content

dineroDomain

function dineroDomain<TCurrency>(currency): IntervalDomain<Dinero<number, TCurrency>>;

Defined in: interval-dinero.ts:56

Build an IntervalDomain for one dinero.js currency. DISCRETE — the epsilon is one minor unit at the currency’s standard exponent. All stepping/measuring/serialization happens in those minor units; compare defers to dinero’s own (scale-aware) comparison. createDineroInterval wraps this in a class; use the domain directly with parseInterval/mergeIntervals.

Type Parameter
TCurrency extends string
Parameter Type
currency DineroCurrency<number, TCurrency>

IntervalDomain<Dinero<number, TCurrency>>

import { dinero, toDecimal, USD } from "dinero.js";
import { parseInterval } from "@xtandard/lib/interval";
import { dineroDomain } from "@xtandard/lib/dinero";
const usdDomain = dineroDomain(USD);
usdDomain.name; // "dinero:USD"
toDecimal(usdDomain.next!(dinero({ amount: 199, currency: USD }))); // "2.00"
parseInterval(usdDomain, "[0,999]").length(); // 1000 (cents $0.00..$9.99)