eventemitter3
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -43,2 +43,4 @@ 'use strict'; | ||
if (1 === length) { | ||
if (fn.__EE3_once) this.removeListener(event, fn); | ||
switch (len) { | ||
@@ -71,4 +73,2 @@ case 1: | ||
} | ||
if (fn.__EE3_once) this.removeListener(event, fn); | ||
} else { | ||
@@ -80,4 +80,4 @@ for (i = 1, args = new Array(len -1); i < len; i++) { | ||
for (i = 0; i < length; fn = listeners[++i]) { | ||
if (fn.__EE3_once) this.removeListener(event, fn); | ||
fn.apply(fn.__EE3_context || this, args); | ||
if (fn.__EE3_once) this.removeListener(event, fn); | ||
} | ||
@@ -84,0 +84,0 @@ } |
{ | ||
"name": "eventemitter3", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface. This the source of the same EventEmitter that is used in Primus.", | ||
@@ -20,4 +20,8 @@ "main": "index.js", | ||
"pub/sub", | ||
"publish", | ||
"subscribe", | ||
"event", | ||
"emitter" | ||
"emitter", | ||
"addListener", | ||
"addEventListener" | ||
], | ||
@@ -30,6 +34,6 @@ "author": "Arnout Kazemier", | ||
"devDependencies": { | ||
"mocha": "1.13.x", | ||
"mocha": "1.18.x", | ||
"pre-commit": "0.0.x", | ||
"chai": "1.8.x" | ||
"chai": "1.9.x" | ||
} | ||
} |
@@ -125,2 +125,16 @@ 'use strict'; | ||
it('only emits once if emits are nested inside the listener', function () { | ||
var e = new EventEmitter() | ||
, calls = 0; | ||
e.once('foo', function () { | ||
calls++; | ||
e.emit('foo'); | ||
}); | ||
e.emit('foo'); | ||
expect(e.listeners('foo').length).to.equal(0); | ||
expect(calls).to.equal(1); | ||
}); | ||
it('only emits once for multiple events', function () { | ||
@@ -127,0 +141,0 @@ var e = new EventEmitter() |
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
32114
20
885