Nearly Perpendicular Macaroons

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

    0.2.0 • Public • Published

    Installation

    npm install --save @types/money

    Summary

    This package contains type definitions for money (https://github.com/openexchangerates/money.js).

    Details

    Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/money.

    index.d.ts

    // Type definitions for money 0.2
    // Project: https://github.com/openexchangerates/money.js
    // Definitions by: Ivan Ergunov <https://github.com/hozblok>
    // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
    
    declare namespace fx {
        type Currency = string;
    
        type Rates = Record<string, number | string>;
    
        interface Options {
            from?: Currency;
            to?: Currency;
        }
    
        type Value = string | number | string[] | number[];
    
        type Result<T_VAL extends Value> = T_VAL extends string | number ? number : number[];
    
        interface Wrapper<T_VAL extends Value> {
            convert: (opts?: Options) => Result<T_VAL>;
    
            from: (currency: Currency) => Wrapper<T_VAL>;
    
            to: (currency: Currency) => Result<T_VAL>;
        }
    
        interface FX {
            /**
             * If fx(val) is called as a function, it returns a wrapped object that can be used OO-style
             */
            <T_VAL extends Value>(val: T_VAL): Wrapper<T_VAL>;
            new <T_VAL extends Value>(val: T_VAL): Wrapper<T_VAL>;
    
            /**
             * Current version
             */
            version: string;
    
            /**
             * Object containing exchange rates relative to the fx.base currency, eg { "GBP" : "0.64" }
             */
            rates: Rates;
    
            /**
             * Default exchange rate base currency (eg "USD"), which all the exchange rates are relative to
             */
            base: Currency;
    
            /**
             * Default from / to currencies for conversion via `convert()`
             */
            settings: {
                from: Currency;
                to: Currency;
            };
    
            /**
             * Converts a value from one currency to another
             */
            convert: <T_VAL extends Value>(val: T_VAL, opts?: Options) => Result<T_VAL>;
        }
    }
    
    /**
     * Library for realtime currency conversion and exchange rate calculation
     */
    declare const fx: fx.FX;
    
    export as namespace fx;
    
    export = fx;

    Additional Details

    • Last updated: Wed, 27 Jul 2022 10:32:19 GMT
    • Dependencies: none
    • Global values: fx

    Credits

    These definitions were written by Ivan Ergunov.

    Keywords

    none

    Install

    npm i @types/money

    DownloadsWeekly Downloads

    197

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    6.35 kB

    Total Files

    5

    Last publish

    Collaborators

    • types