Skip to content

Instantly share code, notes, and snippets.

@Saneyan
Created October 15, 2013 02:10
Show Gist options
  • Select an option

  • Save Saneyan/6985518 to your computer and use it in GitHub Desktop.

Select an option

Save Saneyan/6985518 to your computer and use it in GitHub Desktop.
Simple namespace system for NodeJS
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];
});
};
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