1.0.2 • Published 2 years ago

uni-convert-currency v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Getting started

Installation

This package can be installed using npm

npm install uni-convert-currency

or, yarn

yarn add uni-convert-currency

Usage

Import uni-convert-currency.

const UCC = require('uni-convert-currency')

Then instantiate with either the empty constructor

let currencyConverter = new UCC()

Or, with a json object

let currencyConverter = new UCC({from:"USD", to:"JPY", amount:100})
let currencyConverter = new UCC({from:"USD", to:"JPY", amount:100, isDecimalComma:true})

The convert method will return the conversion based on the last conversion rate and can be used as a promise.

currencyConverter.convert().then((response) => {
    console.log(response) //or do something else
})

convert can also take the amount as a parameter.

currencyConverter.convert(100).then((response) => {
    console.log(response) //or do something else
})

To find the rates use the rates method.

currencyConverter.rates().then((response) => {
    console.log(response) //or do something else
})

Chaining is also supported.

currencyConverter.from("USD").to("GBP").amount(125).convert().then((response) => {
    console.log(response) //or do something else
})

License

This project is licensed under the MIT license.

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.2.4

2 years ago