Skip to content

Latest commit

 

History

History
88 lines (51 loc) · 2.5 KB

quickjs.md

File metadata and controls

88 lines (51 loc) · 2.5 KB

quickjs-emscriptenGlobalsQuickJS

Class: QuickJS

QuickJS presents a Javascript interface to QuickJS, a Javascript interpreter that supports ES2019.

QuickJS is a singleton. Use the getQuickJS function to instantiate or retrieve an instance.

Use the QuickJS.createVm method to create a QuickJSVm.

Use the QuickJS.evalCode method as a shortcut evaluate Javascript safely and return the result as a native Javascript value.

Hierarchy

  • QuickJS

Index

Constructors

Methods

Constructors

constructor

+ new QuickJS(): QuickJS

Defined in quickjs.ts:714

Returns: QuickJS

Methods

createVm

createVm(): QuickJSVm

Defined in quickjs.ts:765

Create a QuickJS VM.

Each VM is completely independent - you cannot share handles between VMs.

Returns: QuickJSVm


evalCode

evalCode(code: string, options: QuickJSEvalOptions): unknown

Defined in quickjs.ts:803

One-off evaluate code without needing to create a VM.

To protect against infinite loops, use the shouldInterrupt option. The shouldInterruptAfterDeadline function will create a time-based deadline.

If you need more control over how the code executes, create a QuickJSVm instance and use its QuickJSVm.evalCode method.

throws If code throws during evaluation, the exception will be converted into a native Javascript value and thrown.

throws if options.shouldInterrupt interrupted execution, will throw a Error with name "InternalError" and message "interrupted".

Parameters:

Name Type Default
code string -
options QuickJSEvalOptions {}

Returns: unknown

The result is coerced to a native Javascript value using JSON serialization, so properties and values unsupported by JSON will be dropped.