-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡️ Store existing isolated in global and reuse it (#1914)
most likely improves #1913
- Loading branch information
1 parent
9114ee4
commit 9d62d9d
Showing
6 changed files
with
38 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Isolate } from "isolated-vm"; | ||
import { variablesGlobals } from "./store"; | ||
|
||
export const getOrCreateIsolate = () => { | ||
if (!variablesGlobals.isolate) { | ||
variablesGlobals.isolate = new Isolate(); | ||
} | ||
return variablesGlobals.isolate; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Isolate } from "isolated-vm"; | ||
|
||
export const variablesGlobals = { | ||
isolate: undefined as Isolate | undefined, | ||
}; | ||
|
||
export const resetVariablesGlobals = () => { | ||
variablesGlobals.isolate?.dispose(); | ||
variablesGlobals.isolate = undefined; | ||
}; |