Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

extend with new currency (crypto) #56

Open
StErMi opened this issue Apr 13, 2018 · 3 comments
Open

extend with new currency (crypto) #56

StErMi opened this issue Apr 13, 2018 · 3 comments

Comments

@StErMi
Copy link

StErMi commented Apr 13, 2018

Is it possible to extend the number of currency supported via code?

@edorivai
Copy link
Collaborator

You mean you want to add a missing currency? If so, we gladly accept PR's to currencies.json, and localeFormats.json 😄

@StErMi
Copy link
Author

StErMi commented Apr 13, 2018 via email

@johuder33
Copy link

@StErMi a PR is just a simple step, but maybe you are out of the time, if you wan to register a currency you could do it liek this

const currencyFormatter = require('currency-formatter');

// suppose you are using a Bitcoin symbol like this 'BIT'

// get the default currency options
const defaults = currencyFormatter.defaultCurrency;
// add your custom currency options
const customCurrency = { symbol: 'BIT', code: 'BIT', format: '%v %s' } // where %v is for value and %s is for symbol

// merge your currency options

const myCurrency = { defaults..., ...customCurrency };

// and finally you can call the formatter like usually you do

currencyFormatter.format(2320, myCurrency)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants