Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to get another instance of the module #25

Open
gflandre opened this issue Dec 29, 2015 · 1 comment
Open

Be able to get another instance of the module #25

gflandre opened this issue Dec 29, 2015 · 1 comment

Comments

@gflandre
Copy link

I hope this project is still maintained... It doesn't really look like it is though.

When using the lib in node, it is not possible to use different rates at different places.
This is due to the fact that the module is a singleton.

I suggest a method to get a fresh instance of fx on which different rates could be set.
It could work like this:

var fx = require('money');
// Global settings
fx.base = 'EUR';
fx.rates = { 'USD': 0.9 };

// convert using the global settings

var myVerySpecialMethod = function () {
  var myLocalFx = fx.clone();
  // these settings are only applied to that local instance
  myLocalFx.base = 'CHF';
  myLocalFx.rates = { 'USD': 2.5 };

  // convert using the local settings
};

This way the current API would still work.

@gflandre
Copy link
Author

Some inspiration: starsirius@a736a83

This was referenced Dec 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant