diff --git a/index.js b/index.js index eb8be512..388b0dcc 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ module.exports = Emitter; */ function Emitter(obj) { - if (!(this instanceof Emitter)) return mixin(obj); + if (obj) return mixin(obj); this._callbacks = {}; }; diff --git a/test/emitter.js b/test/emitter.js index 6f53f5ca..4dcc68d7 100644 --- a/test/emitter.js +++ b/test/emitter.js @@ -1,6 +1,22 @@ var Emitter = require('..'); +function Custom() { + Emitter.call(this) +} + +Custom.prototype.__proto__ = Emitter.prototype; + +describe('Custom', function(){ + describe('with Emitter.call(this)', function(){ + it('should work', function(done){ + var emitter = new Custom; + emitter.on('foo', done); + emitter.emit('foo'); + }) + }) +}) + describe('Emitter', function(){ describe('.on(event, fn)', function(){ it('should add listeners', function(){