Comparing version 1.0.0-1532691371168 to 1.0.0-1532810720851
@@ -9,2 +9,3 @@ export declare type Listener = { | ||
emit<K extends keyof T>(event: K, msg: T[K]): void; | ||
emitAsync<K extends keyof T>(event: K, msg: T[K]): void; | ||
on<K extends keyof T>(event: K, cb: (msg: T[K]) => void): void; | ||
@@ -11,0 +12,0 @@ once<K extends keyof T>(event: K, cb: (msg: T[K]) => void): void; |
@@ -15,2 +15,14 @@ var EventEmitter = /** @class */ (function () { | ||
}; | ||
EventEmitter.prototype.emitAsync = function (event, msg) { | ||
var listeners = this.events.get(event) || []; | ||
setTimeout(function () { | ||
for (var i = listeners.length - 1; i >= 0; i--) { | ||
var listener = listeners[i]; | ||
listener.cb(msg); | ||
if (listener.once) { | ||
listeners.splice(i, 1); | ||
} | ||
} | ||
}); | ||
}; | ||
EventEmitter.prototype.on = function (event, cb) { | ||
@@ -17,0 +29,0 @@ this.addListener(event, cb, false); |
@@ -9,2 +9,3 @@ export declare type Listener = { | ||
emit<K extends keyof T>(event: K, msg: T[K]): void; | ||
emitAsync<K extends keyof T>(event: K, msg: T[K]): void; | ||
on<K extends keyof T>(event: K, cb: (msg: T[K]) => void): void; | ||
@@ -11,0 +12,0 @@ once<K extends keyof T>(event: K, cb: (msg: T[K]) => void): void; |
@@ -17,2 +17,14 @@ "use strict"; | ||
}; | ||
EventEmitter.prototype.emitAsync = function (event, msg) { | ||
var listeners = this.events.get(event) || []; | ||
setTimeout(function () { | ||
for (var i = listeners.length - 1; i >= 0; i--) { | ||
var listener = listeners[i]; | ||
listener.cb(msg); | ||
if (listener.once) { | ||
listeners.splice(i, 1); | ||
} | ||
} | ||
}); | ||
}; | ||
EventEmitter.prototype.on = function (event, cb) { | ||
@@ -19,0 +31,0 @@ this.addListener(event, cb, false); |
{ | ||
"name": "betsy", | ||
"version": "1.0.0-1532691371168", | ||
"version": "1.0.0-1532810720851", | ||
"description": "Typed events", | ||
@@ -5,0 +5,0 @@ "author": "Christian Alfoni <christianalfoni@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23945
254