Skip to content

Instantly share code, notes, and snippets.

@pyykkis
Created March 21, 2013 21:31
Show Gist options
  • Save pyykkis/5216983 to your computer and use it in GitHub Desktop.
Save pyykkis/5216983 to your computer and use it in GitHub Desktop.
Browserify transformer to bind 'this' to module.exports.
through = require('through');
module.exports = function (file) {
var tr = through(null, function () {
this.queue('}).call(module.exports)'); this.queue(null) }); tr.pause();
tr.queue('(function(){'); process.nextTick(tr.resume.bind(tr)); return tr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment