Some PR comments/build issue.
This commit is contained in:
parent
3e21d97c47
commit
285916d0bf
|
@ -15,6 +15,17 @@ export class BuiltInVM implements VM {
|
|||
this.span = span
|
||||
}
|
||||
|
||||
withContext<T>(context: Record<string, any>, executeWithContext: () => T): T {
|
||||
this.ctx = vm.createContext(context)
|
||||
try {
|
||||
return executeWithContext()
|
||||
} finally {
|
||||
for (const key in context) {
|
||||
delete this.ctx[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
execute(code: string) {
|
||||
const perRequestLimit = env.JS_PER_REQUEST_TIMEOUT_MS
|
||||
let track: TrackerFn = f => f()
|
||||
|
|
|
@ -97,11 +97,11 @@ export class IsolatedVM implements VM {
|
|||
return this
|
||||
}
|
||||
|
||||
withContext<T>(context: Record<string, any>, f: () => T) {
|
||||
withContext<T>(context: Record<string, any>, executeWithContext: () => T) {
|
||||
this.addToContext(context)
|
||||
|
||||
try {
|
||||
return f()
|
||||
return executeWithContext()
|
||||
} finally {
|
||||
this.removeFromContext(Object.keys(context))
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ export class VM2 implements VM {
|
|||
this.vm.setGlobal("results", this.results)
|
||||
}
|
||||
|
||||
withContext<T>(context: Record<string, any>, fn: () => T): T {
|
||||
withContext<T>(context: Record<string, any>, executeWithContext: () => T): T {
|
||||
this.vm.setGlobals(context)
|
||||
try {
|
||||
return fn()
|
||||
return executeWithContext()
|
||||
} finally {
|
||||
for (const key in context) {
|
||||
this.vm.setGlobal(key, undefined)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export interface VM {
|
||||
execute(code: string): any
|
||||
withContext<T>(context: Record<string, any>, fn: () => T): T
|
||||
withContext<T>(context: Record<string, any>, executeWithContext: () => T): T
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue