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 <[email protected]>

PR-URL: #33556
Refs: #33527
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Bradley Farias <[email protected]>
  • Loading branch information
jasnell authored and codebytere committed Jun 18, 2020
1 parent 20d54f6 commit 1c70b18
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 1c70b18

Please sign in to comment.