node package manager


EventEmitter Everywhere… Excelsior!

Sorry, couldn't resist the alliteration. One of the ironies of the emergence of NodeJS is that for all the glory it brings to Javascript it also is at odds with the place where Javascript has reigned supreme for many years, the browser. Most of the NodeJS libraries are unavailable in the browser. The Events module's EventEmitter was one of those features that exists NodeJS side but not in the browser. This was mostly limiting not because the browser couldn't handle it but because writing code that could / should run everywhere needed to becareful to use common libraries. Common-Emitter is meant to help alleviate that issue.


npm install common-emitter


Use exactly like you would EventEmitter. When running in a NodeJS environment it actually just facilitates the requiring of EventEmitter. But when running in a browser environment Common-Emitter provides the common interface so you can write code that run everywhere Javascript does.

The excellent Underscore library is needed for the browser implementation. This is required from within the Common-Emitter code. Using a server like Proxy-Hem or a server that uses Stitch will make it so this is a non-issue. Otherwise, Common-Emitter will check to see if '_' is in the window object so simple load the underscore script first and you should be fine.