Skip to content

Instantly share code, notes, and snippets.

@jfsiii
Created June 6, 2011 15:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfsiii/1010501 to your computer and use it in GitHub Desktop.
Save jfsiii/1010501 to your computer and use it in GitHub Desktop.
(function(){
function Klass(id){ this._id = id; }
Klass.prototype.id = function(){ console.log(this._id); }
var freeExports = typeof exports == 'object' && exports;
if (freeExports) {
for (var prop in Klass) freeExports[prop] = Klass[prop];
} else if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
define(function() { return Klass; });
} else {
// use square bracket notation so Closure Compiler won't mung `Klass`
// http://code.google.com/closure/compiler/docs/api-tutorial3.html#export
window['Klass'] = Klass;
}
})();
> var Klass = require('./js/boilerplate.js')
> var foo = new Klass('foo')
TypeError: object is not a function
at Object.CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
at [object Context]:1:11
at Interface.<anonymous> (repl.js:171:22)
at Interface.emit (events.js:64:17)
at Interface._onLine (readline.js:153:10)
at Interface._line (readline.js:408:8)
at Interface._ttyWrite (readline.js:585:14)
at ReadStream.<anonymous> (readline.js:73:12)
at ReadStream.emit (events.js:81:20)
at ReadStream._emitKey (tty_posix.js:307:10)
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment