We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bfb518e commit 7fab10bCopy full SHA for 7fab10b
EventEmitter/emitter.js
@@ -0,0 +1,17 @@
1
+'use strict';
2
+
3
+global.EventEmitter = function() {
4
+ this.events = {};
5
+};
6
7
+EventEmitter.prototype.on = function(name, callback) {
8
+ this.events[name] = this.events[name] || [];
9
+ this.events[name].push(callback);
10
11
12
+EventEmitter.prototype.emit = function(name, data) {
13
+ var event = this.events[name];
14
+ if (event) event.forEach(function(callback) {
15
+ callback(data);
16
+ });
17
0 commit comments