Environment agnostic event emitter solution for JavaScript