@yaupon/money
TypeScript icon, indicating that this package has built-in type declarations

0.0.0-dev • Public • Published

💸 Money

Tiny dinero.js@alpha wrapper which provides additional dictionary of currencies, typings and guards for working with currencies and databases in real-world applications and overall bunch of type aliases to simplify workflow in TypeScript.

type CurrencyDictionary = {
    [key in keyof typeof DineroCurrencies & string]: Currency;
};
declare const currencies: CurrencyDictionary;
/**
 * This is a type alias for Dinero.
 */
declare var Money: typeof Dinero;
/**
 * This is a type alias for Dinero.Currency<number>.
 */
type Currency = Dinero.Currency<number>;
type CurrencyCode = Tagged<keyof typeof DineroCurrencies, "currency_code">;
declare function isCurrencyCode(value: unknown): value is CurrencyCode;
declare function assertCurrencyCode(value: unknown): asserts value is CurrencyCode;
/**
 * Returns a Dinero.Currency object for the given currency code.
 *
 * @param currency The ISO-4217 Currency Code.
 */
declare function getCurrencyByCode(currency: CurrencyCode): Currency;
/**
 * Function will validate if provided value is a valid Dinero.Currency object.
 * This is validation which allows definition of custom currency objects once
 * they are compatible with Dinero.Currency<number> type.
 * @param value
 */
declare function isCurrency(value: unknown): value is Currency;
/**
 * Function will validate if provided value is a valid Dinero.Currency object.
 * @param value
 */
declare function assertCurrency(value: unknown): asserts value is Currency;
/**
 * Function will define currency object, this is useful for defining custom currency objects
 * @param currency
 */
declare function defineCurrency(currency: Currency): Currency;

Readme

Keywords

none

Package Sidebar

Install

npm i @yaupon/money

Weekly Downloads

0

Version

0.0.0-dev

License

ISC

Unpacked Size

10.9 kB

Total Files

7

Last publish

Collaborators

  • keinsell