DRY
This commit is contained in:
parent
d293abc8e8
commit
d1d005dbbc
|
@ -205,8 +205,8 @@ export class IsolatedVM implements VM {
|
||||||
|
|
||||||
script.evaluateSync({ timeout: this.#timeout })
|
script.evaluateSync({ timeout: this.#timeout })
|
||||||
|
|
||||||
const result = this.#getResult()
|
const result = this.#getFromContext(this.#resultKey)
|
||||||
return result
|
return result.out
|
||||||
}
|
}
|
||||||
|
|
||||||
#registerCallbacks(functions: Record<string, any>) {
|
#registerCallbacks(functions: Record<string, any>) {
|
||||||
|
@ -241,13 +241,9 @@ export class IsolatedVM implements VM {
|
||||||
}
|
}
|
||||||
|
|
||||||
#getFromContext(key: string) {
|
#getFromContext(key: string) {
|
||||||
return this.#jail.getSync(key)
|
const ref = this.#vm.global.getSync(key, { reference: true })
|
||||||
}
|
|
||||||
|
|
||||||
#getResult() {
|
|
||||||
const ref = this.#vm.global.getSync(this.#resultKey, { reference: true })
|
|
||||||
const result = ref.copySync()
|
const result = ref.copySync()
|
||||||
ref.release()
|
ref.release()
|
||||||
return result.out
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue