Created
October 15, 2013 02:10
-
-
Save Saneyan/6985518 to your computer and use it in GitHub Desktop.
Simple namespace system for NodeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.usingNamespace = function (global) { | |
| var objs = Array.prototype.slice.call(arguments, 1); | |
| objs.forEach(function (obj) { | |
| var prop; | |
| for (prop in obj) | |
| global[prop] = obj[prop]; | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var usingNamespace = require('./gfns'); | |
| usingNamespace(GLOBAL, | |
| require('./myMod_1'), | |
| require('./myMod_2'), | |
| require('./myMod_3')); | |
| // Import 'myMethod' from 'myMod_1' | |
| myMethod('Hello, world.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment