试图继承EvenEmitter时,我有一个错误
/* Consumer.js */
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var Consumer = function() {};
Consumer.prototype = {
// ... functions ...
findById: function(id) {
this.emit('done', this);
}
};
util.inherits(Consumer, EventEmitter);
module.exports = Consumer;
/* index.js */
var consumer = new Consumer();
consumer.on('done', function(result) {
console.log(result);
}).findById("50ac3d1281abba5454000001");
/* ERROR CODE */
{"code":"InternalError","message":"Object [object Object] has no method 'findById'"}
我已经试过几乎所有的东西,仍然不工作