-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
90 lines (81 loc) · 2.51 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="data:," />
<title>Nomad</title>
<script referrerpolicy="no-referrer" src="../../dist/umd/index.js"></script>
<script type="module" referrerpolicy="no-referrer">
'use strict';
const { vmCreate, dependencyFrom } = nomad;
const vm = vmCreate();
vm.on('**', (...args) => console.log(args));
const dbl = dependencyFrom(() => (x) => 2 * x, 'dbl');
const qpl = dependencyFrom(
(duplicateA = dbl, duplicateB = dbl) =>
(x) =>
duplicateA(duplicateB(x)),
'qpl',
);
await vm.start().then(() => {
console.log('BOOTED');
});
await vm.install('root', dbl);
await vm.install('root', qpl);
await vm.predefine('root', 'none', () => {});
await vm
.execute(
'root',
dependencyFrom(function x(quad = qpl) {
return quad(42);
}),
)
.then((result) => {
console.log(`RESULT = ${result}`);
});
await vm
.execute(
'root',
dependencyFrom(function x() {
return new Date(0).constructor === Date;
}),
)
.then((result) => {
console.log(`RESULT = ${result}`);
});
await vm
.execute(
'root',
dependencyFrom(function x() {
return [new Date(1714022362739).toDateString(), new Date(1714022362739).toTimeString()];
}),
)
.then((result) => {
console.log(`RESULT = ${result}`);
console.log(`typeof RESULT = ${typeof result}`);
console.log(`RESULT.constructor.name = ${result.constructor.name}`);
console.log(`[RESULT] = [${result.map((x) => `"${x}"`).join(', ')}]`);
});
await vm
.execute(
'root',
dependencyFrom(function x() {
return new Error('hello').stack;
}),
)
.then((result) => console.log(`>>> ${result}`));
await vm
.execute(
'root',
dependencyFrom(function x() {
return __events__.on.toString();
}),
)
.then((result) => console.log(`>>> ${result}`));
await vm.listInstalled('root').then((result) => console.log(`>>> INSTALLED: ${result}`));
await vm.listRootEnclosures().then((result) => console.log(`>>> ENCLOSURES: ${result}`));
console.dir(vm);
</script>
</head>
<body></body>
</html>