@sebastianwessel/quickjs v3.0.0
@sebastianwessel/quickjs / SandboxBaseOptions
Type Alias: SandboxBaseOptions
SandboxBaseOptions =
object
Defined in: types/SandboxOptions.ts:12
Properties
allowFetch?
optionalallowFetch:boolean
Defined in: types/SandboxOptions.ts:45
Allow code to make http(s) calls. When enabled, the global fetch will be available
allowFs?
optionalallowFs:boolean
Defined in: types/SandboxOptions.ts:40
Enable file capabilities If enabled, the package node:fs becomes available
console?
optionalconsole:object
Defined in: types/SandboxOptions.ts:60
Per default, the console log inside of QuickJS is passed to the host console log. Here, you can customize the handling and provide your own logging methods.
assert()?
optionalassert: (condition?, ...data) =>void
Parameters
condition?
boolean
data?
...unknown[]
Returns
void
clear()?
optionalclear: () =>void
Returns
void
count()?
optionalcount: (label?) =>void
Parameters
label?
string
Returns
void
countReset()?
optionalcountReset: (label?) =>void
Parameters
label?
string
Returns
void
debug()?
optionaldebug: (message?, ...optionalParams) =>void
Parameters
message?
unknown
optionalParams?
...unknown[]
Returns
void
dir()?
optionaldir: (item?,options?) =>void
Parameters
item?
unknown
options?
object
Returns
void
dirxml()?
optionaldirxml: (...data) =>void
Parameters
data
...unknown[]
Returns
void
error()?
optionalerror: (message?, ...optionalParams) =>void
Parameters
message?
unknown
optionalParams?
...unknown[]
Returns
void
group()?
optionalgroup: (...label) =>void
Parameters
label
...unknown[]
Returns
void
groupCollapsed()?
optionalgroupCollapsed: (...label) =>void
Parameters
label
...unknown[]
Returns
void
groupEnd()?
optionalgroupEnd: () =>void
Returns
void
info()?
optionalinfo: (message?, ...optionalParams) =>void
Parameters
message?
unknown
optionalParams?
...unknown[]
Returns
void
log()?
optionallog: (message?, ...optionalParams) =>void
Parameters
message?
unknown
optionalParams?
...unknown[]
Returns
void
table()?
optionaltable: (tabularData?,properties?) =>void
Parameters
tabularData?
unknown
properties?
string[]
Returns
void
time()?
optionaltime: (label?) =>void
Parameters
label?
string
Returns
void
timeEnd()?
optionaltimeEnd: (label?) =>void
Parameters
label?
string
Returns
void
timeLog()?
optionaltimeLog: (label?, ...data) =>void
Parameters
label?
string
data?
...unknown[]
Returns
void
trace()?
optionaltrace: (message?, ...optionalParams) =>void
Parameters
message?
unknown
optionalParams?
...unknown[]
Returns
void
warn()?
optionalwarn: (message?, ...optionalParams) =>void
Parameters
message?
unknown
optionalParams?
...unknown[]
Returns
void
dangerousSync?
optionaldangerousSync:Record<string,unknown>
Defined in: types/SandboxOptions.ts:104
The object is synchronized between host and guest system. This means, the values on the host, can be set by the guest system
enableTestUtils?
optionalenableTestUtils:boolean
Defined in: types/SandboxOptions.ts:55
Includes test framework If enabled, the packages chai and mocha become available They are registered global
env?
optionalenv:Record<string,unknown>
Defined in: types/SandboxOptions.ts:99
Key-value list of ENV vars, which should be available in QuickJS It is not limited to primitives like string and numbers. Objects, arrays and functions can be provided as well.
Example
// in config
{
env: {
My_ENV: 'my var'
}
}
// inside of QuickJS
console.log(env.My_ENV) // outputs: my varexecutionTimeout?
optionalexecutionTimeout:number
Defined in: types/SandboxOptions.ts:17
The maximum time in milliseconds a script can run. Unset or set to 0 for unlimited execution time.
fetchAdapter?
optionalfetchAdapter: typeoffetch
Defined in: types/SandboxOptions.ts:49
The custom fetch adapter provided as host function in the QuickJS runtime
maxIntervalCount?
optionalmaxIntervalCount:number
Defined in: types/SandboxOptions.ts:134
As the interval function is injected from host to client, in theory the client could create a massive amount of intervals, which are executed by the host. This might impact the host. Because of this, the maximum concurrent running intervals is limited by this option.
Default
10maxStackSize?
optionalmaxStackSize:number
Defined in: types/SandboxOptions.ts:21
Set the max stack size for this runtime, in bytes. To remove the limit, set to 0.
maxTimeoutCount?
optionalmaxTimeoutCount:number
Defined in: types/SandboxOptions.ts:126
As the timeout function is injected from host to client, in theory the client could create a massive amount of timeouts, which are executed by the host. This might impact the host. Because of this, the maximum concurrent running timeouts is limited by this option.
Default
10memoryLimit?
optionalmemoryLimit:number
Defined in: types/SandboxOptions.ts:25
Set the max memory this runtime can allocate. To remove the limit, set to -1
mountFs?
optionalmountFs:NestedDirectoryJSON|IFs
Defined in: types/SandboxOptions.ts:30
Mount a virtual file system
Link
https://github.com/streamich/memfs
nodeModules?
optionalnodeModules:NestedDirectoryJSON
Defined in: types/SandboxOptions.ts:35
Mount custom node_modules in a virtual file system
Link
https://github.com/streamich/memfs
transformCompilerOptions?
optionaltransformCompilerOptions:TS.CompilerOptions
Defined in: types/SandboxOptions.ts:118
The Typescript compiler options for transpiling files from typescript to JavaScript
transformTypescript?
optionaltransformTypescript:boolean
Defined in: types/SandboxOptions.ts:114
Transpile all typescript files to javascript file in mountFs Requires dependency typescript to be installed
typescriptImportFile?
optionaltypescriptImportFile:string
Defined in: types/SandboxOptions.ts:109
The Typescript lib to import
Default
typescript