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>
  • Loading branch information
jasnell committed May 27, 2020
1 parent e14786f commit 5f34554
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 5f34554

Please sign in to comment.