Dirty. Names are assigned directly into GLOBAL
. It breaks file scope.
main.js
using = require('using').using
using(require('foo'))
console.log(new Foo) #=> { name: 'Foo' }
require('bar')
using.js
exports.using = function (mod) {
for (var name in mod)
GLOBAL[name] = mod[name]
}
foo.js
exports.Foo = function () {
this.name = 'Foo'
}
bar.js
console.log(new Foo) #=> { name: 'Foo' }
There may be another way but I can't find it...