forked from primus/eventemitter3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Till Sanders <[email protected]>
- Loading branch information
1 parent
b2d3a4b
commit eb6b351
Showing
23 changed files
with
2,699 additions
and
1,006 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.github | ||
dist | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
"overrides": [], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"rules": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
node_modules/ | ||
coverage/ | ||
dist/ | ||
.tern-port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.github | ||
dist | ||
coverage | ||
package.json | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,69 @@ | ||
'use strict'; | ||
"use strict"; | ||
|
||
var benchmark = require('benchmark'); | ||
import { Suite } from "benchmark"; | ||
|
||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter1 = require('events').EventEmitter | ||
, EventEmitter3 = require('eventemitter3') | ||
, Drip = require('drip').EventEmitter | ||
, CE = require('contra/emitter') | ||
, EE = require('event-emitter') | ||
, FE = require('fastemitter') | ||
import { EventEmitter2 } from "eventemitter2"; | ||
import { EventEmitter as EventEmitter1 } from "events"; | ||
import EventEmitter3 from "eventemitter3"; | ||
import { EventEmitter as Drip } from "drip"; | ||
import CE from "contra/emitter"; | ||
import EE from "event-emitter"; | ||
import FE from "fastemitter"; | ||
|
||
import('../../dist/index.js').then((ESMitter) => { | ||
import("../../dist/index.js").then((ESMitter) => { | ||
const Master = ESMitter.ESMitter; | ||
|
||
function handle() { | ||
if (arguments.length > 100) console.log('damn'); | ||
if (arguments.length > 100) console.log("damn"); | ||
} | ||
|
||
var ee1 = new EventEmitter1() | ||
, ee2 = new EventEmitter2() | ||
, ee3 = new EventEmitter3() | ||
, master = new Master() | ||
, drip = new Drip() | ||
, fe = new FE() | ||
, ce = CE() | ||
, ee = EE(); | ||
var ee1 = new EventEmitter1(), | ||
ee2 = new EventEmitter2(), | ||
ee3 = new EventEmitter3(), | ||
master = new Master(), | ||
drip = new Drip(), | ||
fe = new FE(), | ||
ce = CE(), | ||
ee = EE(); | ||
|
||
( | ||
new benchmark.Suite() | ||
).add('EventEmitter1', function() { | ||
ee1.on('foo', handle); | ||
ee1.removeListener('foo', handle); | ||
}).add('EventEmitter2', function() { | ||
ee2.on('foo', handle); | ||
ee2.removeListener('foo', handle); | ||
}).add('[email protected]', function() { | ||
ee3.on('foo', handle); | ||
ee3.removeListener('foo', handle); | ||
}).add('ESMitter(main)', function() { | ||
master.on('foo', handle); | ||
master.removeListener('foo', handle); | ||
}).add('Drip', function() { | ||
drip.on('foo', handle); | ||
drip.removeListener('foo', handle); | ||
}).add('fastemitter', function() { | ||
fe.on('foo', handle); | ||
fe.removeListener('foo', handle); | ||
}).add('event-emitter', function() { | ||
ee.on('foo', handle); | ||
ee.off('foo', handle); | ||
}).add('contra/emitter', function() { | ||
ce.on('foo', handle); | ||
ce.off('foo', handle); | ||
}).on('cycle', function cycle(e) { | ||
console.log(e.target.toString()); | ||
}).on('complete', function completed() { | ||
console.log('Fastest is %s', this.filter('fastest').map('name')); | ||
}).run({ async: true }); | ||
}); | ||
new Suite() | ||
.add("EventEmitter1", function () { | ||
ee1.on("foo", handle); | ||
ee1.removeListener("foo", handle); | ||
}) | ||
.add("EventEmitter2", function () { | ||
ee2.on("foo", handle); | ||
ee2.removeListener("foo", handle); | ||
}) | ||
.add("[email protected]", function () { | ||
ee3.on("foo", handle); | ||
ee3.removeListener("foo", handle); | ||
}) | ||
.add("ESMitter(main)", function () { | ||
master.on("foo", handle); | ||
master.removeListener("foo", handle); | ||
}) | ||
.add("Drip", function () { | ||
drip.on("foo", handle); | ||
drip.removeListener("foo", handle); | ||
}) | ||
.add("fastemitter", function () { | ||
fe.on("foo", handle); | ||
fe.removeListener("foo", handle); | ||
}) | ||
.add("event-emitter", function () { | ||
ee.on("foo", handle); | ||
ee.off("foo", handle); | ||
}) | ||
.add("contra/emitter", function () { | ||
ce.on("foo", handle); | ||
ce.off("foo", handle); | ||
}) | ||
.on("cycle", function cycle(e) { | ||
console.log(e.target.toString()); | ||
}) | ||
.on("complete", function completed() { | ||
console.log("Fastest is %s", this.filter("fastest").map("name")); | ||
}) | ||
.run({ async: true }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,96 @@ | ||
'use strict'; | ||
"use strict"; | ||
|
||
var benchmark = require('benchmark'); | ||
import { Suite } from "benchmark"; | ||
|
||
var EventEmitter2 = require('eventemitter2').EventEmitter2 | ||
, EventEmitter1 = require('events').EventEmitter | ||
, EventEmitter3 = require('eventemitter3') | ||
, Drip = require('drip').EventEmitter | ||
, CE = require('contra/emitter') | ||
, EE = require('event-emitter') | ||
, FE = require('fastemitter') | ||
import { EventEmitter2 } from "eventemitter2"; | ||
import { EventEmitter as EventEmitter1 } from "events"; | ||
import EventEmitter3 from "eventemitter3"; | ||
import { EventEmitter as Drip } from "drip"; | ||
import CE from "contra/emitter"; | ||
import EE from "event-emitter"; | ||
import FE from "fastemitter"; | ||
|
||
import('../../dist/index.js').then((ESMitter) => { | ||
import("../../dist/index.js").then((ESMitter) => { | ||
const Master = ESMitter.ESMitter; | ||
|
||
var ctx = { foo: 'bar' }; | ||
var ctx = { foo: "bar" }; | ||
|
||
function handle() { | ||
if (arguments.length > 100) console.log('damn'); | ||
if (arguments.length > 100) console.log("damn"); | ||
} | ||
|
||
var ee1 = new EventEmitter1() | ||
, ee2 = new EventEmitter2() | ||
, ee3 = new EventEmitter3() | ||
, master = new Master() | ||
, drip = new Drip() | ||
, fe = new FE() | ||
, ce = CE() | ||
, ee = EE(); | ||
var ee1 = new EventEmitter1(), | ||
ee2 = new EventEmitter2(), | ||
ee3 = new EventEmitter3(), | ||
master = new Master(), | ||
drip = new Drip(), | ||
fe = new FE(), | ||
ce = CE(), | ||
ee = EE(); | ||
|
||
ee3.on('foo', handle, ctx); | ||
ee2.on('foo', handle.bind(ctx)); | ||
ee1.on('foo', handle.bind(ctx)); | ||
drip.on('foo', handle.bind(ctx)); | ||
master.on('foo', handle, ctx); | ||
ee.on('foo', handle.bind(ctx)); | ||
fe.on('foo', handle.bind(ctx)); | ||
ce.on('foo', handle.bind(ctx)); | ||
ee3.on("foo", handle, ctx); | ||
ee2.on("foo", handle.bind(ctx)); | ||
ee1.on("foo", handle.bind(ctx)); | ||
drip.on("foo", handle.bind(ctx)); | ||
master.on("foo", handle, ctx); | ||
ee.on("foo", handle.bind(ctx)); | ||
fe.on("foo", handle.bind(ctx)); | ||
ce.on("foo", handle.bind(ctx)); | ||
|
||
( | ||
new benchmark.Suite() | ||
).add('EventEmitter1', function() { | ||
ee1.emit('foo'); | ||
ee1.emit('foo', 'bar'); | ||
ee1.emit('foo', 'bar', 'baz'); | ||
ee1.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('EventEmitter2', function() { | ||
ee2.emit('foo'); | ||
ee2.emit('foo', 'bar'); | ||
ee2.emit('foo', 'bar', 'baz'); | ||
ee2.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('[email protected]', function() { | ||
ee3.emit('foo'); | ||
ee3.emit('foo', 'bar'); | ||
ee3.emit('foo', 'bar', 'baz'); | ||
ee3.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('ESMitter(main)', function() { | ||
master.emit('foo'); | ||
master.emit('foo', 'bar'); | ||
master.emit('foo', 'bar', 'baz'); | ||
master.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('Drip', function() { | ||
drip.emit('foo'); | ||
drip.emit('foo', 'bar'); | ||
drip.emit('foo', 'bar', 'baz'); | ||
drip.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('fastemitter', function() { | ||
fe.emit('foo'); | ||
fe.emit('foo', 'bar'); | ||
fe.emit('foo', 'bar', 'baz'); | ||
fe.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('event-emitter', function() { | ||
ee.emit('foo'); | ||
ee.emit('foo', 'bar'); | ||
ee.emit('foo', 'bar', 'baz'); | ||
ee.emit('foo', 'bar', 'baz', 'boom'); | ||
}).add('contra/emitter', function() { | ||
ce.emit('foo'); | ||
ce.emit('foo', 'bar'); | ||
ce.emit('foo', 'bar', 'baz'); | ||
ce.emit('foo', 'bar', 'baz', 'boom'); | ||
}).on('cycle', function cycle(e) { | ||
console.log(e.target.toString()); | ||
}).on('complete', function completed() { | ||
console.log('Fastest is %s', this.filter('fastest').map('name')); | ||
}).run({ async: true }); | ||
new Suite() | ||
.add("EventEmitter1", function () { | ||
ee1.emit("foo"); | ||
ee1.emit("foo", "bar"); | ||
ee1.emit("foo", "bar", "baz"); | ||
ee1.emit("foo", "bar", "baz", "boom"); | ||
}) | ||
.add("EventEmitter2", function () { | ||
ee2.emit("foo"); | ||
ee2.emit("foo", "bar"); | ||
ee2.emit("foo", "bar", "baz"); | ||
ee2.emit("foo", "bar", "baz", "boom"); | ||
}) | ||
.add("[email protected]", function () { | ||
ee3.emit("foo"); | ||
ee3.emit("foo", "bar"); | ||
ee3.emit("foo", "bar", "baz"); | ||
ee3.emit("foo", "bar", "baz", "boom"); | ||
}) | ||
.add("ESMitter(main)", function () { | ||
master.emit("foo"); | ||
master.emit("foo", "bar"); | ||
master.emit("foo", "bar", "baz"); | ||
master.emit("foo", "bar", "baz", "boom"); | ||
}) | ||
.add("Drip", function () { | ||
drip.emit("foo"); | ||
drip.emit("foo", "bar"); | ||
drip.emit("foo", "bar", "baz"); | ||
drip.emit("foo", "bar", "baz", "boom"); | ||
}) | ||
.add("fastemitter", function () { | ||
fe.emit("foo"); | ||
fe.emit("foo", "bar"); | ||
fe.emit("foo", "bar", "baz"); | ||
fe.emit("foo", "bar", "baz", "boom"); | ||
}) | ||
.add("event-emitter", function () { | ||
ee.emit("foo"); | ||
ee.emit("foo", "bar"); | ||
ee.emit("foo", "bar", "baz"); | ||
ee.emit("foo", "bar", "baz", "boom"); | ||
}) | ||
.add("contra/emitter", function () { | ||
ce.emit("foo"); | ||
ce.emit("foo", "bar"); | ||
ce.emit("foo", "bar", "baz"); | ||
ce.emit("foo", "bar", "baz", "boom"); | ||
}) | ||
.on("cycle", function cycle(e) { | ||
console.log(e.target.toString()); | ||
}) | ||
.on("complete", function completed() { | ||
console.log("Fastest is %s", this.filter("fastest").map("name")); | ||
}) | ||
.run({ async: true }); | ||
}); |
Oops, something went wrong.