That might not work so well with the structure of the library, but I'm open to calling it something else, if enough people say it's an issue - so feel free to fork it and do a pull request.
--- money.js
+++ money.js
@@ -13,6 +13,8 @@
return new fxWrapper(obj);
};
+ var NS = 'CurrencyConverter';
+
// Current version.
fx.version = '0.0.1';
@@ -122,28 +124,14 @@
// Otherwise, just add `fx` to the global object
if (typeof module !== 'undefined' && module.exports) {
module.exports = fx;
- fx.fx = fx;
+ fx[NS] = fx;
} else if (typeof define === 'function' && define.amd) {
// Return the library as an AMD module:
define([], function() {
return fx;
});
} else {
- // Use fx.noConflict to restore `fx` back to its original value before money.js loaded.
- // Returns a reference to the library's `fx` object; e.g. `var money = fx.noConflict();`
- fx.noConflict = (function(previousFx) {
- return function() {
- // Reset the value of the root's `fx` variable:
- root.fx = previousFx;
- // Delete the noConflict function:
- fx.noConflict = undefined;
- // Return reference to the library to re-assign it:
- return fx;
- };
- })(root.fx);
-
- // Declare `fx` on the root (global/window) object:
- root['fx'] = fx;
+ root[NS] = fx;
}
// Root will be `window` in browser or `global` on the server:
You can change NS to whatever you like, but I believe that this is all you need to do. Because everything internally uses the enclosed `var fx`, I don't foresee issues.