UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

29 lines (28 loc) 1.34 kB
import type { ImmutableArray } from "./array.js"; import type { AnyCaller } from "./function.js"; /** ISO 4217 currency code, e.g. `GBP` or `USD`. */ export type CurrencyCode = string; /** Array of all supported currency codes in this runtime. */ export declare const CURRENCY_CODES: ImmutableArray<CurrencyCode>; /** * Require that a value is a valid ISO 4217 currency code, and return it as a `Currency` type. */ export declare function getCurrencyCode(value: string): CurrencyCode | undefined; /** * Require that a value is a valid ISO 4217 currency code, and return it as a `Currency` type. */ export declare function requireCurrencyCode(value: string, caller?: AnyCaller): CurrencyCode; /** * Get the display symbol used for a currency. * * @throws {RequiredError} If the currency code is malformed or unsupported. * * @example getCurrencySymbol("GBP"); // "£" */ export declare function getCurrencySymbol(currency: CurrencyCode, caller?: AnyCaller): string; /** * Get the "step" value for a currency, i.e. the smallest fractional unit that is used for that currency. * - E.g. `0.01` for USD, `0.001` for some cryptocurrencies, and `1` for JPY. * @throws {RequiredError} If the currency code is malformed or unsupported. */ export declare function getCurrencyStep(currency: CurrencyCode, caller?: AnyCaller): number;