Skip to content

Commit 07cb5d7

Browse files
save file
1 parent 147fb2f commit 07cb5d7

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Almostnode in the Browser</title>
6+
</head>
7+
<body>
8+
<h1>Open your browser console to see the output!</h1>
9+
10+
<script type="module">
11+
// Load almostnode directly from an ESM-friendly CDN
12+
import { createContainer } from 'https://esm.sh/almostnode';
13+
14+
async function init() {
15+
16+
const container = createContainer();
17+
18+
// Run some Node.js code right here in the client browser
19+
const result = await container.execute(`
20+
21+
const events = require('events');
22+
const emitter = new events.EventEmitter();
23+
24+
emitter.on('greet', (name) => {
25+
console.log('Node Event Emitter says: Hello ' + name);
26+
});
27+
28+
emitter.emit('greet', 'World');
29+
30+
`);
31+
32+
}
33+
34+
init();
35+
36+
37+
</script>
38+
</body>
39+
</html>
40+

0 commit comments

Comments
 (0)