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
// @ts-check js
import * as acorn from "npm:acorn";
import escope from "npm:escope";
import { permitted } from "https://raw.githubusercontent.com/endojs/endo/b463c57d3081d5ca945b2fa72bd73b7b84c53df5/packages/ses/src/permits.js";
const primordials_names = Object.entries(permitted)
.map(([key, value]) => key)
.filter((item) => !(item.startsWith("%") && item.endsWith("%")))
.filter((item) => (item != "Atomics"));
primordials_names.push("E");
// https://github.com/endojs/endo/blob/b463c57d3081d5ca945b2fa72bd73b7b84c53df5/packages/ses/src/permits.js
const t1 = `
console.log("sæll heimur");
const snuð = "hefur ekkert að segja.";
const fall = (ccc) => {
return snuð + tala;
};
const t1 = new Array();
E(t1).foo();
`;
const tala = 42;
const t1_old = ((x) => {
return x.ble + tala;
}).toString();
const t2 = acorn.parse(t1, {ecmaVersion: 2020});
const t3 = escope.analyze(t2, {ecmaVersion: 2020 });
const t4 = t3.scopes[0].through.map((ref) => ref.identifier.name);
const t5 = t4.filter((item) => !primordials_names.includes(item));
console.dir(t5);
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.