Skip to content

Instantly share code, notes, and snippets.

@javruben
Forked from fjakobs/declare.js
Created November 9, 2010 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javruben/668949 to your computer and use it in GitHub Desktop.
Save javruben/668949 to your computer and use it in GitHub Desktop.
if (!module.constructor.prototype.declare) {
module.constructor.prototype.declare = function(deps, factory) {
if (!factory)
factory = deps;
var _self = this;
var req = function(id) {
if (id.indexOf("./") == 0)
id = _self.filename.match(/(.*\/)/)[1] + id.slice(2)
return require(id);
}
factory(req, this.exports, this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment