Am currently working on a project where I require to inherit from EventEmitter. I need an array to emit events on certain cases, say, when some length has been exceeded.
I used this snippet:
var events = require('events');
Array.prototype.__proto__ = events.EventEmitter.prototype;
It works fine, but it is said it is anti-pattern.
In another question, it is suggested to use:
util.inherits(Array, events.EventEmitter.prototype);
But it does NOT work. So what is the right way to do this?