Skip to content

@sebastianwessel/quickjs v2.1.1


@sebastianwessel/quickjs / SandboxBaseOptions

Type Alias: SandboxBaseOptions

SandboxBaseOptions: object

Defined in: src/types/SandboxOptions.ts:12

Type declaration

allowFetch?

optional allowFetch: boolean

Allow code to make http(s) calls. When enabled, the global fetch will be available

allowFs?

optional allowFs: boolean

Enable file capabilities If enabled, the package node:fs becomes available

console?

optional console: object

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.

console.assert()?

optional assert: (condition?, ...data) => void

Parameters
condition?

boolean

data?

...unknown[]

Returns

void

console.clear()?

optional clear: () => void

Returns

void

console.count()?

optional count: (label?) => void

Parameters
label?

string

Returns

void

console.countReset()?

optional countReset: (label?) => void

Parameters
label?

string

Returns

void

console.debug()?

optional debug: (message?, ...optionalParams) => void

Parameters
message?

unknown

optionalParams?

...unknown[]

Returns

void

console.dir()?

optional dir: (item?, options?) => void

Parameters
item?

unknown

options?

object

Returns

void

console.dirxml()?

optional dirxml: (...data) => void

Parameters
data

...unknown[]

Returns

void

console.error()?

optional error: (message?, ...optionalParams) => void

Parameters
message?

unknown

optionalParams?

...unknown[]

Returns

void

console.group()?

optional group: (...label) => void

Parameters
label

...unknown[]

Returns

void

console.groupCollapsed()?

optional groupCollapsed: (...label) => void

Parameters
label

...unknown[]

Returns

void

console.groupEnd()?

optional groupEnd: () => void

Returns

void

console.info()?

optional info: (message?, ...optionalParams) => void

Parameters
message?

unknown

optionalParams?

...unknown[]

Returns

void

console.log()?

optional log: (message?, ...optionalParams) => void

Parameters
message?

unknown

optionalParams?

...unknown[]

Returns

void

console.table()?

optional table: (tabularData?, properties?) => void

Parameters
tabularData?

unknown

properties?

string[]

Returns

void

console.time()?

optional time: (label?) => void

Parameters
label?

string

Returns

void

console.timeEnd()?

optional timeEnd: (label?) => void

Parameters
label?

string

Returns

void

console.timeLog()?

optional timeLog: (label?, ...data) => void

Parameters
label?

string

data?

...unknown[]

Returns

void

console.trace()?

optional trace: (message?, ...optionalParams) => void

Parameters
message?

unknown

optionalParams?

...unknown[]

Returns

void

console.warn()?

optional warn: (message?, ...optionalParams) => void

Parameters
message?

unknown

optionalParams?

...unknown[]

Returns

void

dangerousSync?

optional dangerousSync: Record<string, unknown>

The object is synchronized between host and guest system. This means, the values on the host, can be set by the guest system

enableTestUtils?

optional enableTestUtils: boolean

Includes test framework If enabled, the packages chai and mocha become available They are registered global

env?

optional env: Record<string, unknown>

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

js
// in config
{
  env: {
    My_ENV: 'my var'
  }
}

// inside of QuickJS
console.log(env.My_ENV) // outputs: my var

executionTimeout?

optional executionTimeout: number

The maximum time in milliseconds a script can run. Unset or set to 0 for unlimited execution time.

fetchAdapter?

optional fetchAdapter: typeof fetch

The custom fetch adapter provided as host function in the QuickJS runtime

maxIntervalCount?

optional maxIntervalCount: number

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

ts
100

maxStackSize?

optional maxStackSize: number

Set the max stack size for this runtime, in bytes. To remove the limit, set to 0.

maxTimeoutCount?

optional maxTimeoutCount: number

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

ts
100

memoryLimit?

optional memoryLimit: number

Set the max memory this runtime can allocate. To remove the limit, set to -1

mountFs?

optional mountFs: NestedDirectoryJSON | IFs

Mount a virtual file system

https://github.com/streamich/memfs

nodeModules?

optional nodeModules: NestedDirectoryJSON

Mount custom node_modules in a virtual file system

https://github.com/streamich/memfs

transformCompilerOptions?

optional transformCompilerOptions: TS.CompilerOptions

The Typescript compiler options for transpiling files from typescript to JavaScript

transformTypescript?

optional transformTypescript: boolean

Transpile all typescript files to javascript file in mountFs Requires dependency typescript to be installed

typescriptImportFile?

optional typescriptImportFile: string

The Typescript lib to import

Default

ts
typescript