Clean code

This commit is contained in:
Adria Navarro 2024-02-05 10:18:49 +01:00
parent 8dfcc3aeb1
commit 75f8b40cc4
1 changed files with 4 additions and 4 deletions

View File

@ -25,14 +25,14 @@ class ScriptRunner {
class IsolatedVM {
isolate: ivm.Isolate
vm: ivm.Context
jail: ivm.Reference
#jail: ivm.Reference
script: any
constructor({ memoryLimit }: { memoryLimit: number }) {
this.isolate = new ivm.Isolate({ memoryLimit })
this.vm = this.isolate.createContextSync()
this.jail = this.vm.global
this.jail.setSync("global", this.jail.derefInto())
this.#jail = this.vm.global
this.#jail.setSync("global", this.#jail.derefInto())
}
getValue(key: string) {
@ -44,7 +44,7 @@ class IsolatedVM {
set context(context: Record<string, any>) {
for (let key in context) {
this.jail.setSync(key, this.copyRefToVm(context[key]))
this.#jail.setSync(key, this.copyRefToVm(context[key]))
}
}