eventemitter3
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -15,4 +15,6 @@ { | ||
"microtime": "~0.4.0", | ||
"eventemitter2": "~0.4.13" | ||
"eventemitter2": "*", | ||
"eventemitter3": "*", | ||
"drip": "*" | ||
} | ||
} |
@@ -18,4 +18,6 @@ 'use strict'; | ||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter3 = require('../../').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter; | ||
, EventEmitter3 = require('eventemitter3').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter | ||
, Master = require('../../').EventEmitter | ||
, Drip = require('drip').EventEmitter; | ||
@@ -31,3 +33,5 @@ function handle() { | ||
, ee3 = new EventEmitter3() | ||
, ee1 = new EventEmitter1(); | ||
, ee1 = new EventEmitter1() | ||
, master = new Master() | ||
, drip = new Drip(); | ||
@@ -37,2 +41,4 @@ ee3.on('foo', handle, logger); | ||
ee1.on('foo', handle.bind(logger)); | ||
drip.on('foo', handle.bind(logger)); | ||
master.on('foo', handle.bind(logger)); | ||
@@ -56,2 +62,12 @@ ( | ||
ee3.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('EventEmitter 3 (master)', function test2() { | ||
master.emit('foo'); | ||
master.emit('foo', 'bar'); | ||
master.emit('foo', 'bar', 'baz'); | ||
master.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('Drip', function test2() { | ||
drip.emit('foo'); | ||
drip.emit('foo', 'bar'); | ||
drip.emit('foo', 'bar', 'baz'); | ||
drip.emit('foo', 'bar', 'baz', 'boom'); | ||
}).on('cycle', function cycle(e) { | ||
@@ -58,0 +74,0 @@ var details = e.target; |
@@ -18,4 +18,6 @@ 'use strict'; | ||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter3 = require('../../').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter; | ||
, EventEmitter3 = require('eventemitter3').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter | ||
, Master = require('../../').EventEmitter | ||
, Drip = require('drip').EventEmitter; | ||
@@ -31,3 +33,5 @@ function handle() { | ||
, ee3 = new EventEmitter3() | ||
, ee1 = new EventEmitter1(); | ||
, ee1 = new EventEmitter1() | ||
, master = new Master() | ||
, drip = new Drip(); | ||
@@ -37,2 +41,4 @@ ee3.on('foo', handle); | ||
ee1.on('foo', handle); | ||
drip.on('foo', handle); | ||
master.on('foo', handle); | ||
@@ -56,2 +62,12 @@ ( | ||
ee3.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('EventEmitter 3 (master)', function test2() { | ||
master.emit('foo'); | ||
master.emit('foo', 'bar'); | ||
master.emit('foo', 'bar', 'baz'); | ||
master.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('Drip', function test2() { | ||
drip.emit('foo'); | ||
drip.emit('foo', 'bar'); | ||
drip.emit('foo', 'bar', 'baz'); | ||
drip.emit('foo', 'bar', 'baz', 'boom'); | ||
}).on('cycle', function cycle(e) { | ||
@@ -58,0 +74,0 @@ var details = e.target; |
@@ -18,4 +18,6 @@ 'use strict'; | ||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter3 = require('../../').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter; | ||
, EventEmitter3 = require('eventemitter3').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter | ||
, Master = require('../../').EventEmitter | ||
, Drip = require('drip').EventEmitter; | ||
@@ -34,2 +36,4 @@ function foo() { | ||
, ee1 = new EventEmitter1() | ||
, master = new Master() | ||
, drip = new Drip() | ||
, j, i; | ||
@@ -40,14 +44,6 @@ | ||
ee1.on('event:' + i, foo); | ||
} | ||
} | ||
for (i = 0; i < 10; i++) { | ||
for (j = 0; j < 10; j++) { | ||
ee2.on('event:' + i, foo); | ||
} | ||
} | ||
for (i = 0; i < 10; i++) { | ||
for (j = 0; j < 10; j++) { | ||
ee3.on('event:' + i, foo); | ||
drip.on('event:' + i, foo); | ||
master.on('event:' + i, foo); | ||
} | ||
@@ -70,2 +66,10 @@ } | ||
} | ||
}).add('EventEmitter 3 (master)', function test2() { | ||
for (i = 0; i < 10; i++) { | ||
master.emit('event:' + i); | ||
} | ||
}).add('Drip', function test2() { | ||
for (i = 0; i < 10; i++) { | ||
drip.emit('event:' + i); | ||
} | ||
}).on('cycle', function cycle(e) { | ||
@@ -72,0 +76,0 @@ var details = e.target; |
@@ -18,4 +18,6 @@ 'use strict'; | ||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter3 = require('../../').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter; | ||
, EventEmitter3 = require('eventemitter3').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter | ||
, Master = require('../../').EventEmitter | ||
, Drip = require('drip').EventEmitter; | ||
@@ -30,2 +32,6 @@ ( | ||
var ee = new EventEmitter3(); | ||
}).add('EventEmitter 3 (master)', function test3() { | ||
var ee = new Master(); | ||
}).add('Drip', function test3() { | ||
var drip = new Drip(); | ||
}).on('cycle', function cycle(e) { | ||
@@ -32,0 +38,0 @@ var details = e.target; |
'use strict'; | ||
return; | ||
/** | ||
@@ -17,5 +19,5 @@ * Benchmark related modules. | ||
*/ | ||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter3 = require('../../').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter; | ||
var EventEmitter3 = require('eventemitter3').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter | ||
, Master = require('../../').EventEmitter; | ||
@@ -29,9 +31,14 @@ function handle() { | ||
*/ | ||
var ee2 = new EventEmitter2() | ||
, ee3 = new EventEmitter3() | ||
, ee1 = new EventEmitter1(); | ||
var ee3 = new EventEmitter3() | ||
, ee1 = new EventEmitter1() | ||
, master = new Master(); | ||
ee1.setMaxListeners(Infinity); | ||
ee2.setMaxListeners(Infinity); | ||
// | ||
// EE2 doesn't correctly handle listeners as they can be removed by doing a | ||
// ee2.listeners('foo').length = 0; kills the event emitter, same counts for | ||
// Drip | ||
// | ||
( | ||
@@ -42,12 +49,8 @@ new benchmark.Suite() | ||
ee1.listeners('foo'); | ||
// | ||
// // EE2 doesn't correctly handle listeners as they can be removed by doing a | ||
// // ee2.listeners('foo').length = 0; kills the event emitter | ||
// }).add('EventEmitter 2', function test2() { | ||
// ee2.on('foo', handle); | ||
// ee2.listeners('foo'); | ||
// | ||
}).add('EventEmitter 3', function test2() { | ||
ee3.on('foo', handle); | ||
ee3.listeners('foo'); | ||
}).add('EventEmitter 3 (master)', function test2() { | ||
master.on('foo', handle); | ||
master.listeners('foo'); | ||
}).on('cycle', function cycle(e) { | ||
@@ -54,0 +57,0 @@ var details = e.target; |
@@ -18,4 +18,6 @@ 'use strict'; | ||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter3 = require('../../').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter; | ||
, EventEmitter3 = require('eventemitter3').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter | ||
, Master = require('../../').EventEmitter | ||
, Drip = require('drip').EventEmitter; | ||
@@ -31,3 +33,5 @@ function handle() { | ||
, ee3 = new EventEmitter3() | ||
, ee1 = new EventEmitter1(); | ||
, ee1 = new EventEmitter1() | ||
, master = new Master() | ||
, drip = new Drip(); | ||
@@ -45,2 +49,8 @@ ( | ||
ee3.removeListener('foo', handle); | ||
}).add('EventEmitter 3 (master)', function test2() { | ||
master.on('foo', handle); | ||
master.removeListener('foo', handle); | ||
}).add('Drip', function test2() { | ||
drip.on('foo', handle); | ||
drip.removeListener('foo', handle); | ||
}).on('cycle', function cycle(e) { | ||
@@ -47,0 +57,0 @@ var details = e.target; |
@@ -18,4 +18,6 @@ 'use strict'; | ||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter3 = require('../../').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter; | ||
, EventEmitter3 = require('eventemitter3').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter | ||
, Master = require('../../').EventEmitter | ||
, Drip = require('drip').EventEmitter; | ||
@@ -45,3 +47,5 @@ function foo() { | ||
, ee3 = new EventEmitter3() | ||
, ee1 = new EventEmitter1(); | ||
, ee1 = new EventEmitter1() | ||
, master = new Master() | ||
, drip = new Drip(); | ||
@@ -51,2 +55,4 @@ ee3.on('foo', foo).on('foo', bar).on('foo', baz); | ||
ee1.on('foo', foo).on('foo', bar).on('foo', baz); | ||
drip.on('foo', foo).on('foo', bar).on('foo', baz); | ||
master.on('foo', foo).on('foo', bar).on('foo', baz); | ||
@@ -70,2 +76,12 @@ ( | ||
ee3.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('EventEmitter 3 (master)', function test2() { | ||
master.emit('foo'); | ||
master.emit('foo', 'bar'); | ||
master.emit('foo', 'bar', 'baz'); | ||
master.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('Drip', function test2() { | ||
drip.emit('foo'); | ||
drip.emit('foo', 'bar'); | ||
drip.emit('foo', 'bar', 'baz'); | ||
drip.emit('foo', 'bar', 'baz', 'boom'); | ||
}).on('cycle', function cycle(e) { | ||
@@ -72,0 +88,0 @@ var details = e.target; |
@@ -18,4 +18,6 @@ 'use strict'; | ||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter3 = require('../../').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter; | ||
, EventEmitter3 = require('eventemitter3').EventEmitter | ||
, EventEmitter1 = require('events').EventEmitter | ||
, Master = require('../../').EventEmitter | ||
, Drip = require('drip').EventEmitter; | ||
@@ -31,3 +33,5 @@ function handle() { | ||
, ee3 = new EventEmitter3() | ||
, ee1 = new EventEmitter1(); | ||
, ee1 = new EventEmitter1() | ||
, master = new Master() | ||
, drip = new Drip(); | ||
@@ -45,2 +49,8 @@ ( | ||
ee3.emit('foo'); | ||
}).add('EventEmitter 3 (master)', function test2() { | ||
master.once('foo', handle); | ||
master.emit('foo'); | ||
}).add('Drip', function test2() { | ||
drip.once('foo', handle); | ||
drip.emit('foo'); | ||
}).on('cycle', function cycle(e) { | ||
@@ -47,0 +57,0 @@ var details = e.target; |
43
index.js
@@ -46,28 +46,15 @@ 'use strict'; | ||
switch (len) { | ||
case 1: | ||
fn.call(fn.__EE3_context || this); | ||
break; | ||
case 2: | ||
fn.call(fn.__EE3_context || this, a1); | ||
break; | ||
case 3: | ||
fn.call(fn.__EE3_context || this, a1, a2); | ||
break; | ||
case 4: | ||
fn.call(fn.__EE3_context || this, a1, a2, a3); | ||
break; | ||
case 5: | ||
fn.call(fn.__EE3_context || this, a1, a2, a3, a4); | ||
break; | ||
case 6: | ||
fn.call(fn.__EE3_context || this, a1, a2, a3, a4, a5); | ||
break; | ||
case 1: return fn.call(fn.__EE3_context), true; | ||
case 2: return fn.call(fn.__EE3_context, a1), true; | ||
case 3: return fn.call(fn.__EE3_context, a1, a2), true; | ||
case 4: return fn.call(fn.__EE3_context, a1, a2, a3), true; | ||
case 5: return fn.call(fn.__EE3_context, a1, a2, a3, a4), true; | ||
case 6: return fn.call(fn.__EE3_context, a1, a2, a3, a4, a5), true; | ||
} | ||
default: | ||
for (i = 1, args = new Array(len -1); i < len; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
for (i = 1, args = new Array(len -1); i < len; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
fn.apply(fn.__EE3_context || this, args); | ||
} | ||
fn.apply(fn.__EE3_context, args); | ||
} else { | ||
@@ -80,3 +67,3 @@ for (i = 1, args = new Array(len -1); i < len; i++) { | ||
if (fn.__EE3_once) this.removeListener(event, fn); | ||
fn.apply(fn.__EE3_context || this, args); | ||
fn.apply(fn.__EE3_context, args); | ||
} | ||
@@ -100,3 +87,3 @@ } | ||
fn.__EE3_context = context; | ||
fn.__EE3_context = context || this; | ||
this._events[event].push(fn); | ||
@@ -133,4 +120,4 @@ | ||
for (var i = 0, length = listeners.length; i < length; i++) { | ||
if (fn && listeners[i] !== fn) { | ||
if (fn) for (var i = 0, length = listeners.length; i < length; i++) { | ||
if (listeners[i] !== fn) { | ||
events.push(listeners[i]); | ||
@@ -137,0 +124,0 @@ } |
{ | ||
"name": "eventemitter3", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"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.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# EventEmitter3 | ||
EventEmitter3 is a faster alternative to EventEmitter2 and the build-in | ||
EventEmitter3 is a faster alternative to EventEmitter2 and the built-in | ||
EventEmitter that ships within Node.js. It removes some features that you might | ||
@@ -19,7 +19,7 @@ not need: | ||
It's a drop in replacement of your existing EventEmitters, but just faster. Free | ||
performance, who wouldn't want that. | ||
performance, who wouldn't want that? | ||
The source of the EventEmitter is compatible for browser usage, no fancy pancy | ||
`Array.isArray` stuff is used, it's just plain ol JavaScript that should even | ||
work IE5 if you want to. This module currently serves it's use in | ||
work IE5 if you want to. This module currently serves its use in | ||
[Primus](http://github.com/primus/primus)'s client file. | ||
@@ -26,0 +26,0 @@ |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
34946
919
0