Skip to content

Commit

Permalink
events: initial implementation of experimental EventTarget
Browse files Browse the repository at this point in the history
See documentation changes for details

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: #33556
Refs: #33527
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
  • Loading branch information
jasnell committed May 28, 2020
1 parent 47044a9 commit 785842a
Show file tree
Hide file tree
Showing 8 changed files with 1,316 additions and 0 deletions.
24 changes: 24 additions & 0 deletions benchmark/events/eventtarget.js
@@ -0,0 +1,24 @@
'use strict';
const common = require('../common.js');

const bench = common.createBenchmark(main, {
n: [2e7],
listeners: [1, 5, 10]
}, { flags: ['--expose-internals'] });

function main({ n, listeners }) {
const { EventTarget, Event } = require('internal/event_target');
const target = new EventTarget();

for (let n = 0; n < listeners; n++)
target.addEventListener('foo', () => {});

const event = new Event('foo');

bench.start();
for (let i = 0; i < n; i++) {
target.dispatchEvent(event);
}
bench.end(n);

}
5 changes: 5 additions & 0 deletions doc/api/errors.md
Expand Up @@ -903,6 +903,11 @@ Encoding provided to `TextDecoder()` API was not one of the

`--print` cannot be used with ESM input.

<a id="ERR_EVENT_RECURSION"></a>
### `ERR_EVENT_RECURSION`

Thrown when an attempt is made to recursively dispatch an event on `EventTarget`.

<a id="ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE"></a>
### `ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE`

Expand Down

0 comments on commit 785842a

Please sign in to comment.