Skip to content

Be able to get another instance of the module #25

Description

@gflandre

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions