1
0
Fork 0
mirror of synced 2024-09-08 13:41:09 +12:00

tidy up args for Isolated VM class

This commit is contained in:
Martin McKeaveney 2024-01-02 10:29:57 +00:00
parent 8f1470f5a5
commit 51c0494b0f

View file

@ -7,7 +7,7 @@ class ScriptRunner {
constructor(script: string, context: any) {
const code = `let fn = () => {\n${script}\n}; results.out = fn();`
this.vm = new IsolatedVM(8)
this.vm = new IsolatedVM({ memoryLimit: 8 })
this.vm.context = {
data: context.data,
params: context.params,
@ -29,7 +29,7 @@ class IsolatedVM {
jail: ivm.Reference
script: any
constructor(memoryLimit: number) {
constructor({ memoryLimit }: { memoryLimit: number }) {
this.isolate = new ivm.Isolate({ memoryLimit })
this.vm = this.isolate.createContextSync()
this.jail = this.vm.global