Skip to content

Commit

Permalink
add demo
Browse files Browse the repository at this point in the history
  • Loading branch information
shirakaba committed Mar 20, 2024
1 parent ed2a53e commit 90d3c33
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-env node */

module.exports = {
root: true,
env: {
node: true,
},
extends: ['../.eslintrc.cjs'],
};
10 changes: 10 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Examples

These example scripts can be run in any JavaScript runtime that supports the prerequisites mentioned in the `README.md` in the repo root. Here's how to run one example using Node, Deno, or Bun:

```sh
# For the example named "basic.js":
node basic.js
deno run basic.js
bun basic.js
```
8 changes: 8 additions & 0 deletions examples/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Event, EventTarget } from '../src/index.js';

const eventTarget = new EventTarget();
const event = new Event('click', {});
eventTarget.addEventListener('click', (event) => {
console.log(`Fired "${event.type}" event!`, event);
});
eventTarget.dispatchEvent(event, 'abc');

0 comments on commit 90d3c33

Please sign in to comment.