Fix builtins syntax highlighting

This commit is contained in:
dylan
2023-05-08 21:48:16 -07:00
parent ad5acdeb12
commit 8c750ac2dc
2 changed files with 17 additions and 13 deletions

View File

@@ -2,8 +2,13 @@
const G: any = {
eval: eval,
};
// deno-lint-ignore no-explicit-any
const builtins: any = {};
const context = new Proxy(G, {
get: (target, prop) => {
if (prop in builtins) {
return builtins[prop as keyof typeof builtins];
}
return target[prop];
},
set: (target, prop, value) => {
@@ -43,9 +48,9 @@ export const evalCode = (code: string) => {
// deno-lint-ignore no-explicit-any
export const addToContext = (name: string, value: any) => {
G[name] = value;
builtins[name] = value;
}
export const getContext = () => {
return G;
export const getBuiltins = () => {
return builtins;
}