Skip to content

Instantly share code, notes, and snippets.

@bengl
Created March 23, 2011 15:22
Show Gist options
  • Save bengl/883274 to your computer and use it in GitHub Desktop.
Save bengl/883274 to your computer and use it in GitHub Desktop.
Because I got tired of var module = require('module');
//using.js
var importThem = function(libs){
for (var i = 0; i < libs.length; i++) {
global[libs[i]] = require(libs[i]);
}
};
module.exports = function(){
if (arguments.length == 1
&& arguments[0].constructor.toString().indexOf("Array") != -1)
importThem(arguments[0]);
else
importThem(arguments);
};
// and then in your app.js:
require('using')('util','fs');
// or
require('using')(['util','fs']);
// would be equivalent to:
util = require('util');
fs = require('fs');
@bengl
Copy link
Author

bengl commented Mar 23, 2011

Does this make me a bad person?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment