createCurrencyPackage
function createCurrencyPackage(config?): IEnginePackage;Defined in: packages/engine/src/packages/currency/CurrencyPackage.ts:33
Currency: $10, £10, €10, ¥10, ₽10, ₩10, ₹10, ₺10, ₴10,
₪10, ₫10, ₦10, ₱10, 10 USD in GBP, 100 USD in GBP on 2024-01-15,
and word forms like 10 euros/10 dollars (see uom/CurrencyAliases.ts for
the full symbol/word alias tables and the ambiguity decisions behind them).
Live rates are fetched asynchronously (via CurrencyAsyncResolver) and
the expression shows Pending until they resolve. The dated on <date> form
resolves through a HOST-SUPPLIED CurrencyPackageConfig.historicalRateProvider
instead, unconfigured, it reports HISTORICAL_RATES_NOT_CONFIGURED plainly
rather than drifting to today’s rate (see uom/HistoricalCurrency.ts).
A factory, but still a default builtin. Unlike stocks (no free provider,
so excluded from BUILTIN_PACKAGES), the LIVE half of currency needs no
configuration, so CURRENCY_PACKAGE = createCurrencyPackage() ships
as a default. The historical resolver is registered either way, so the
grammar always recognises on <date> and answers the not-configured case
honestly; supplying a provider is what turns that error into a real rate. A
host wanting historical conversion calls createCurrencyPackage({ historicalRateProvider })
and swaps the result in for the default in its packages array.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | CurrencyPackageConfig |