@bettercart/rescript-dinero

    0.1.1 • Public • Published

    rescript-dinero

    dinero.js bindings for ReScript

    Installation

    Using NPM:

    npm install --save @bettercart/rescript-dinero

    Using Yarn:

    yarn add @bettercart/rescript-dinero

    Then add @bettercart/rescript-dinero to bs-dependencies in your bsconfig.json:

    {
      ...
      "bs-dependencies": ["@bettercart/rescript-dinero"]
    }

    Usage

    type currency = [
      | #USD
      | #CAD
      | #EUR
    ]
    
    type money = {
      amount: int,
      currency: currency,
    }
    
    let money = {
      amount: 100,
      currency: #USD
    }
    
    let dinero = Dinero.create(
      Dinero.options(~amount=money.amount, ~currency=money.currency->Money.currencyToJs, ()),
    )
    
    <div> {dinero.toFormat(. "$0,0.00", #HALF_AWAY_FROM_ZERO)->React.string} </div>

    Globals

    Dinero has an export for it self global instance Dinero.dineroJs - this will be needed to use the global setters or getters.

    Set Globals

      Dinero.setLocale(Dinero.dineroJs, "us-en")
      
      Dinero.setLocale(Dinero.dineroJs, "us-en")

    Access Globals:

      Dinero.dineroJs.globalLocale

    Install

    npm i @bettercart/rescript-dinero

    DownloadsWeekly Downloads

    90

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    5.25 kB

    Total Files

    6

    Last publish

    Collaborators

    • dan003400