Skip to content

Latest commit

 

History

History
1513 lines (869 loc) · 41.6 KB

File metadata and controls

1513 lines (869 loc) · 41.6 KB

quickjs-emscriptenquickjs-emscriptenReadme | Exports


quickjs-emscripten / quickjs-emscripten

quickjs-emscripten

Contents

Namespaces

Classes

Interfaces

Type Aliases

AsyncFunctionImplementation

AsyncFunctionImplementation: (this, ...args) => Promise<QuickJSHandle | VmCallResult<QuickJSHandle> | void>

Parameters

this: QuickJSHandle

• ...args: QuickJSHandle[]

Returns

Promise<QuickJSHandle | VmCallResult<QuickJSHandle> | void>

Source

packages/quickjs-emscripten-core/dist/index.d.ts:313


BorrowedHeapCharPointer

BorrowedHeapCharPointer: Pointer<"const char" | "char" | "js const char">

Used internally for Javascript-to-C calls that may contain strings too large for the Emscripten stack.

Source

packages/quickjs-ffi-types/dist/index.d.ts:66


EitherFFI

EitherFFI: QuickJSFFI | QuickJSAsyncFFI

Source

packages/quickjs-ffi-types/dist/index.d.ts:496


EitherModule

EitherModule: QuickJSEmscriptenModule | QuickJSAsyncEmscriptenModule

Source

packages/quickjs-ffi-types/dist/index.d.ts:304


ExecutePendingJobsResult

ExecutePendingJobsResult: SuccessOrFail<number, QuickJSHandle & Object>

Used as an optional for the results of executing pendingJobs. On success, value contains the number of async jobs executed by the runtime.

Source

Source

packages/quickjs-emscripten-core/dist/index.d.ts:122


InterruptHandler

InterruptHandler: (runtime) => boolean | undefined

Callback called regularly while the VM executes code. Determines if a VM's execution should be interrupted.

Parameters

runtime: QuickJSRuntime

Returns

boolean | undefined

true to interrupt JS execution inside the VM.

false or undefined to continue JS execution inside the VM.

Source

packages/quickjs-emscripten-core/dist/index.d.ts:115


Intrinsics

Intrinsics: Object

Language features that can be enabled or disabled in a QuickJSContext.

See

ContextOptions

Type declaration

BaseObjects?

BaseObjects?: boolean

BigDecimal?

BigDecimal?: boolean

BigFloat?

BigFloat?: boolean

BigInt?

BigInt?: boolean

BignumExt?

BignumExt?: boolean

Date?

Date?: boolean

Eval?

Eval?: boolean

JSON?

JSON?: boolean

MapSet?

MapSet?: boolean

OperatorOverloading?

OperatorOverloading?: boolean

Promise?

Promise?: boolean

Proxy?

Proxy?: boolean

RegExp?

RegExp?: boolean

RegExpCompiler?

RegExpCompiler?: boolean

StringNormalize?

StringNormalize?: boolean

TypedArrays?

TypedArrays?: boolean

Source

packages/quickjs-emscripten-core/dist/index.d.ts:443


JSBorrowedCharPointer

JSBorrowedCharPointer: Pointer<"js const char">

Used internally for Javascript-to-C calls that may contain strings too large for the Emscripten stack.

Source

packages/quickjs-ffi-types/dist/index.d.ts:76


JSContextPointer

JSContextPointer: Pointer<"JSContext">

JSContext*.

Source

packages/quickjs-ffi-types/dist/index.d.ts:20


JSContextPointerPointer

JSContextPointerPointer: Pointer<"JSContext">

JSContext**. Used internally for execute pending jobs.

Source

packages/quickjs-ffi-types/dist/index.d.ts:24


JSModuleDefPointer

JSModuleDefPointer: Pointer<"JSModuleDef">

JSModuleDef*.

Source

packages/quickjs-ffi-types/dist/index.d.ts:28


JSModuleLoadFailure

JSModuleLoadFailure: Error | QuickJSHandle

Source

packages/quickjs-emscripten-core/dist/index.d.ts:394


JSModuleLoadResult

JSModuleLoadResult: JSModuleLoadSuccess | SuccessOrFail<JSModuleLoadSuccess, JSModuleLoadFailure>

Source

packages/quickjs-emscripten-core/dist/index.d.ts:395


JSModuleLoadSuccess

JSModuleLoadSuccess: string

Source

packages/quickjs-emscripten-core/dist/index.d.ts:393


JSModuleNormalizeFailure

JSModuleNormalizeFailure: Error | QuickJSHandle

Source

packages/quickjs-emscripten-core/dist/index.d.ts:405


JSModuleNormalizeResult

JSModuleNormalizeResult: JSModuleNormalizeSuccess | SuccessOrFail<JSModuleNormalizeSuccess, JSModuleNormalizeFailure>

Source

packages/quickjs-emscripten-core/dist/index.d.ts:406


JSModuleNormalizeSuccess

JSModuleNormalizeSuccess: string

Source

packages/quickjs-emscripten-core/dist/index.d.ts:404


JSPromiseState

JSPromiseState: JSPromiseStatePending | JSPromiseStateFulfilled | JSPromiseStateRejected

A promise state inside QuickJS, which can be pending, fulfilled, or rejected. You can unwrap a JSPromiseState with QuickJSContext#unwrapResult.

Source

packages/quickjs-emscripten-core/dist/index.d.ts:673


JSPromiseStateEnum

JSPromiseStateEnum: Brand<typeof JSPromiseStateEnum[keyof typeof JSPromiseStateEnum], "JSPromiseStateEnum">

State of a promise.

Source

packages/quickjs-ffi-types/dist/index.d.ts:140


JSRuntimePointer

JSRuntimePointer: Pointer<"JSRuntime">

JSRuntime*.

Source

packages/quickjs-ffi-types/dist/index.d.ts:16


JSValue

JSValue: Lifetime<JSValuePointer, JSValuePointer, QuickJSRuntime>

A owned QuickJSHandle that should be disposed or returned.

The QuickJS interpreter passes Javascript values between functions as JSValue structs that references some internal data. Because passing structs cross the Empscripten FFI interfaces is bothersome, we use pointers to these structs instead.

A JSValue reference is "owned" in its scope. before exiting the scope, it should be freed, by calling JS_FreeValue(ctx, js_value)) or returned from the scope. We extend that contract - a JSValuePointer (JSValue*) must also be freed.

You can do so from Javascript by calling the .dispose() method.

Source

packages/quickjs-emscripten-core/dist/index.d.ts:384


JSValueConst

JSValueConst: Lifetime<JSValueConstPointer, JSValuePointer, QuickJSRuntime>

A QuickJSHandle to a borrowed value that does not need to be disposed.

In QuickJS, a JSValueConst is a "borrowed" reference that isn't owned by the current scope. That means that the current scope should not JS_FreeValue it, or retain a reference to it after the scope exits, because it may be freed by its owner.

quickjs-emscripten takes care of disposing JSValueConst references.

Source

packages/quickjs-emscripten-core/dist/index.d.ts:368


JSValueConstPointer

JSValueConstPointer: Pointer<"JSValueConst">

`JSValueConst* See JSValueConst and StaticJSValue.

Source

packages/quickjs-ffi-types/dist/index.d.ts:38


JSValueConstPointerPointer

JSValueConstPointerPointer: Pointer<"JSValueConst[]">

Used internally for Javascript-to-C function calls.

Source

packages/quickjs-ffi-types/dist/index.d.ts:46


JSValuePointer

JSValuePointer: Pointer<"JSValue">

JSValue*. See JSValue.

Source

packages/quickjs-ffi-types/dist/index.d.ts:33


JSValuePointerPointer

JSValuePointerPointer: Pointer<"JSValue[]">

Used internally for Javascript-to-C function calls.

Source

packages/quickjs-ffi-types/dist/index.d.ts:42


JSVoidPointer

JSVoidPointer: Pointer<any>

Opaque pointer that was allocated by js_malloc.

Source

packages/quickjs-ffi-types/dist/index.d.ts:80


OrLoader<T>

OrLoader<T>: T | () => Promise<T>

Type parameters

T

Source

packages/quickjs-emscripten-core/dist/index.d.ts:1532


OwnedHeapCharPointer

OwnedHeapCharPointer: Pointer<"char">

Used internally for Javascript-to-C calls that may contain strings too large for the Emscripten stack.

Source

packages/quickjs-ffi-types/dist/index.d.ts:71


PromiseExecutor<ResolveT, RejectT>

PromiseExecutor<ResolveT, RejectT>: (resolve, reject) => void

Type parameters

ResolveT

RejectT

Parameters

resolve: (value) => void

reject: (reason) => void

Returns

void

Source

packages/quickjs-emscripten-core/dist/index.d.ts:531


PromisedDefault<T>

PromisedDefault<T>: T | Promise<T> | Promise<Object> | Promise<Object>

Type parameters

T

Source

packages/quickjs-emscripten-core/dist/index.d.ts:1473


QTS_C_To_HostCallbackFuncPointer

QTS_C_To_HostCallbackFuncPointer: Pointer<"C_To_HostCallbackFunc">

Used internally for C-to-Javascript function calls.

Source

packages/quickjs-ffi-types/dist/index.d.ts:53


QTS_C_To_HostInterruptFuncPointer

QTS_C_To_HostInterruptFuncPointer: Pointer<"C_To_HostInterruptFunc">

Used internally for C-to-Javascript interrupt handlers.

Source

packages/quickjs-ffi-types/dist/index.d.ts:57


QTS_C_To_HostLoadModuleFuncPointer

QTS_C_To_HostLoadModuleFuncPointer: Pointer<"C_To_HostLoadModuleFunc">

Used internally for C-to-Javascript module loading.

Source

packages/quickjs-ffi-types/dist/index.d.ts:61


QuickJSHandle

QuickJSHandle: StaticJSValue | JSValue | JSValueConst

Wraps a C pointer to a QuickJS JSValue, which represents a Javascript value inside a QuickJS virtual machine.

Values must not be shared between QuickJSContext instances. You must dispose of any handles you create by calling the .dispose() method.

Source

packages/quickjs-emscripten-core/dist/index.d.ts:392


QuickJSPropertyKey

QuickJSPropertyKey: number | string | QuickJSHandle

Property key for getting or setting a property on a handle with QuickJSContext#getProp, QuickJSContext#setProp, or QuickJSContext#defineProp.

Source

packages/quickjs-emscripten-core/dist/index.d.ts:779


QuickJSVariant

QuickJSVariant: QuickJSSyncVariant | QuickJSAsyncVariant

Source

packages/quickjs-ffi-types/dist/index.d.ts:495


StaticJSValue

StaticJSValue: Lifetime<JSValueConstPointer, JSValueConstPointer, QuickJSRuntime>

A QuickJSHandle to a constant that will never change, and does not need to be disposed.

Source

packages/quickjs-emscripten-core/dist/index.d.ts:357


SuccessOrFail<S, F>

SuccessOrFail<S, F>: Object | Object

Used as an optional. { value: S } | { error: E }.

Type parameters

S

F

Source

packages/quickjs-emscripten-core/dist/index.d.ts:17


VmCallResult<VmHandle>

VmCallResult<VmHandle>: SuccessOrFail<VmHandle, VmHandle>

Used as an optional for results of a Vm call. { value: VmHandle } | { error: VmHandle }.

Type parameters

VmHandle

Source

packages/quickjs-emscripten-core/dist/index.d.ts:33


VmFunctionImplementation<VmHandle>

VmFunctionImplementation<VmHandle>: (this, ...args) => VmHandle | VmCallResult<VmHandle> | void

Type parameters

VmHandle

A VmFunctionImplementation takes handles as arguments. It should return a handle, or be void.

To indicate an exception, a VMs can throw either a handle (transferred directly) or any other Javascript value (only the poperties name and message will be transferred). Or, the VmFunctionImplementation may return a VmCallResult's { error: handle } error variant.

VmFunctionImplementation should not free its arguments or its return value. It should not retain a reference to its return value or thrown error.

Parameters

this: VmHandle

• ...args: VmHandle[]

Returns

VmHandle | VmCallResult<VmHandle> | void

Source

packages/quickjs-emscripten-core/dist/index.d.ts:46

Variables

DEBUG_ASYNC

const DEBUG_ASYNC: QuickJSAsyncVariant

@jitl/quickjs-wasmfile-debug-asyncify

Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.

Variable Setting Description
library quickjs The original bellard/quickjs library. Version 2024-01-13+626e0d4e vendored to quickjs-emscripten on 2024-02-11.
releaseMode debug Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs.
syncMode asyncify Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs.
emscriptenInclusion wasm Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant.
exports require import browser workerd Has these package.json export conditions

Source

packages/variant-quickjs-wasmfile-debug-asyncify/dist/index.d.ts:18


DEBUG_SYNC

const DEBUG_SYNC: QuickJSSyncVariant

@jitl/quickjs-wasmfile-debug-sync

Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.

Variable Setting Description
library quickjs The original bellard/quickjs library. Version 2024-01-13+626e0d4e vendored to quickjs-emscripten on 2024-02-11.
releaseMode debug Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs.
syncMode sync The default, normal build. Note that both variants support regular async functions.
emscriptenInclusion wasm Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant.
exports require import browser workerd Has these package.json export conditions

Source

packages/variant-quickjs-wasmfile-debug-sync/dist/index.d.ts:18


DefaultIntrinsics

const DefaultIntrinsics: Readonly<Object>

The default Intrinsics language features enabled in a QuickJSContext.

See

ContextOptions

Type declaration

BaseObjects

readonly BaseObjects: true

Date

readonly Date: true

Eval

readonly Eval: true

JSON

readonly JSON: true

MapSet

readonly MapSet: true

Promise

readonly Promise: true

Proxy

readonly Proxy: true

RegExp

readonly RegExp: true

StringNormalize

readonly StringNormalize: true

TypedArrays

readonly TypedArrays: true

Source

packages/quickjs-emscripten-core/dist/index.d.ts:465


EvalFlags

EvalFlags: Object

Bitfield options for JS_Eval() C function.

Type declaration

JS_EVAL_FLAG_BACKTRACE_BARRIER

readonly JS_EVAL_FLAG_BACKTRACE_BARRIER: number

don't include the stack frames before this eval in the Error() backtraces

JS_EVAL_FLAG_COMPILE_ONLY

readonly JS_EVAL_FLAG_COMPILE_ONLY: number

compile but do not run. The result is an object with a JS_TAG_FUNCTION_BYTECODE or JS_TAG_MODULE tag. It can be executed with JS_EvalFunction().

JS_EVAL_FLAG_STRICT

readonly JS_EVAL_FLAG_STRICT: number

force 'strict' mode

JS_EVAL_FLAG_STRIP

readonly JS_EVAL_FLAG_STRIP: number

force 'strip' mode

JS_EVAL_TYPE_DIRECT

readonly JS_EVAL_TYPE_DIRECT: number

direct call (internal use)

JS_EVAL_TYPE_GLOBAL

readonly JS_EVAL_TYPE_GLOBAL: number

global code (default)

JS_EVAL_TYPE_INDIRECT

readonly JS_EVAL_TYPE_INDIRECT: number

indirect call (internal use)

JS_EVAL_TYPE_MASK

readonly JS_EVAL_TYPE_MASK: number

JS_EVAL_TYPE_MODULE

readonly JS_EVAL_TYPE_MODULE: number

module code

Source

packages/quickjs-ffi-types/dist/index.d.ts:89


IntrinsicsFlags

IntrinsicsFlags: Object

Bitfield options for QTS_NewContext intrinsices

Type declaration

BaseObjects

readonly BaseObjects: number

BigDecimal

readonly BigDecimal: number

BigFloat

readonly BigFloat: number

BigInt

readonly BigInt: number

BignumExt

readonly BignumExt: number

Date

readonly Date: number

Eval

readonly Eval: number

JSON

readonly JSON: number

MapSet

readonly MapSet: number

OperatorOverloading

readonly OperatorOverloading: number

Promise

readonly Promise: number

Proxy

readonly Proxy: number

RegExp

readonly RegExp: number

RegExpCompiler

readonly RegExpCompiler: number

StringNormalize

readonly StringNormalize: number

TypedArrays

readonly TypedArrays: number

Source

packages/quickjs-ffi-types/dist/index.d.ts:117


JSPromiseStateEnum

JSPromiseStateEnum: Object

Type declaration

Fulfilled

readonly Fulfilled: 1

Pending

readonly Pending: 0

Rejected

readonly Rejected: 2

Source

packages/quickjs-ffi-types/dist/index.d.ts:140


RELEASE_ASYNC

const RELEASE_ASYNC: QuickJSAsyncVariant

@jitl/quickjs-wasmfile-release-asyncify

Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.

Variable Setting Description
library quickjs The original bellard/quickjs library. Version 2024-01-13+626e0d4e vendored to quickjs-emscripten on 2024-02-11.
releaseMode release Optimized for performance; use when building/deploying your application.
syncMode asyncify Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The QuickJSAsyncRuntime and QuickJSAsyncContext classes expose the ASYNCIFY-specific APIs.
emscriptenInclusion wasm Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant.
exports require import browser workerd Has these package.json export conditions

Source

packages/variant-quickjs-wasmfile-release-asyncify/dist/index.d.ts:18


RELEASE_SYNC

const RELEASE_SYNC: QuickJSSyncVariant

@jitl/quickjs-wasmfile-release-sync

Docs | Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.

Variable Setting Description
library quickjs The original bellard/quickjs library. Version 2024-01-13+626e0d4e vendored to quickjs-emscripten on 2024-02-11.
releaseMode release Optimized for performance; use when building/deploying your application.
syncMode sync The default, normal build. Note that both variants support regular async functions.
emscriptenInclusion wasm Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant.
exports require import browser workerd Has these package.json export conditions

Source

packages/variant-quickjs-wasmfile-release-sync/dist/index.d.ts:18

Functions

assertSync()

assertSync<Args, R>(fn): (...args) => R

Type parameters

Args extends any[]

R

Parameters

fn: (...args) => R

Returns

Function

Parameters

• ...args: Args

Returns

R

Source

packages/quickjs-ffi-types/dist/index.d.ts:85


getQuickJS()

getQuickJS(): Promise<QuickJSWASMModule>

Get a shared singleton QuickJSWASMModule. Use this to evaluate code or create Javascript environments.

This is the top-level entrypoint for the quickjs-emscripten library.

If you need strictest possible isolation guarantees, you may create a separate QuickJSWASMModule via newQuickJSWASMModule.

To work with the asyncified version of this library, see these functions:

Returns

Promise<QuickJSWASMModule>

Source

packages/quickjs-emscripten/src/mod.ts:28


getQuickJSSync()

getQuickJSSync(): QuickJSWASMModule

Provides synchronous access to the shared QuickJSWASMModule instance returned by getQuickJS, as long as least once.

Returns

QuickJSWASMModule

Throws

If called before getQuickJS resolves.

Source

packages/quickjs-emscripten/src/mod.ts:41


isFail()

isFail<S, F>(successOrFail): successOrFail is Object

Type parameters

S

F

Parameters

successOrFail: SuccessOrFail<S, F>

Returns

successOrFail is Object

Source

packages/quickjs-emscripten-core/dist/index.d.ts:26


isSuccess()

isSuccess<S, F>(successOrFail): successOrFail is Object

Type parameters

S

F

Parameters

successOrFail: SuccessOrFail<S, F>

Returns

successOrFail is Object

Source

packages/quickjs-emscripten-core/dist/index.d.ts:23


memoizePromiseFactory()

memoizePromiseFactory<T>(fn): () => Promise<T>

Helper intended to memoize the creation of a WebAssembly module.

const getDebugModule = memoizePromiseFactory(() => newQuickJSWASMModule(DEBUG_SYNC))

Type parameters

T

Parameters

fn: () => Promise<T>

Returns

Function

Returns

Promise<T>

Source

packages/quickjs-emscripten-core/dist/index.d.ts:1531


newAsyncContext()

newAsyncContext(options?): Promise<QuickJSAsyncContext>

Create a new QuickJSAsyncContext (with an associated runtime) in an separate WebAssembly module.

Each context is isolated in a separate WebAssembly module, so that errors in one runtime cannot contaminate another runtime, and each runtime can execute an asynchronous action without conflicts.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

options?: ContextOptions

Returns

Promise<QuickJSAsyncContext>

Source

packages/quickjs-emscripten/src/mod.ts:76


newAsyncRuntime()

newAsyncRuntime(options?): Promise<QuickJSAsyncRuntime>

Create a new QuickJSAsyncRuntime in a separate WebAssembly module.

Each runtime is isolated in a separate WebAssembly module, so that errors in one runtime cannot contaminate another runtime, and each runtime can execute an asynchronous action without conflicts.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

options?: AsyncRuntimeOptions

Returns

Promise<QuickJSAsyncRuntime>

Source

packages/quickjs-emscripten/src/mod.ts:59


newQuickJSAsyncWASMModule()

newQuickJSAsyncWASMModule(variantOrPromise): Promise<QuickJSAsyncWASMModule>

Create a new, completely isolated WebAssembly module containing a version of the QuickJS library compiled with Emscripten's ASYNCIFY transform.

This version of the library offers features that enable synchronous code inside the VM to interact with asynchronous code in the host environment. See the documentation on QuickJSAsyncWASMModule, QuickJSAsyncRuntime, and QuickJSAsyncContext.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

variantOrPromise: PromisedDefault<QuickJSAsyncVariant>= RELEASE_ASYNC

Optionally, pass a QuickJSAsyncVariant to construct a different WebAssembly module.

Returns

Promise<QuickJSAsyncWASMModule>

Source

packages/quickjs-emscripten/src/variants.ts:47


newQuickJSAsyncWASMModuleFromVariant()

newQuickJSAsyncWASMModuleFromVariant(variantOrPromise): Promise<QuickJSAsyncWASMModule>

Create a new, completely isolated WebAssembly module containing a version of the QuickJS library compiled with Emscripten's ASYNCIFY transform.

This version of the library offers features that enable synchronous code inside the VM to interact with asynchronous code in the host environment. See the documentation on QuickJSAsyncWASMModule, QuickJSAsyncRuntime, and QuickJSAsyncContext.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

variantOrPromise: PromisedDefault<QuickJSAsyncVariant>

A QuickJSAsyncVariant to construct the WebAssembly module.

Returns

Promise<QuickJSAsyncWASMModule>

Example

const quickjs = new newQuickJSAsyncWASMModuleFromVariant(
  import('@jitl/quickjs-browser-debug-asyncify-wasm')
)

Source

packages/quickjs-emscripten-core/dist/index.d.ts:1520


newQuickJSWASMModule()

newQuickJSWASMModule(variantOrPromise): Promise<QuickJSWASMModule>

Create a new, completely isolated WebAssembly module containing the QuickJS library. See the documentation on QuickJSWASMModule.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

variantOrPromise: PromisedDefault<QuickJSSyncVariant>= RELEASE_SYNC

Optionally, pass a QuickJSSyncVariant to construct a different WebAssembly module.

Returns

Promise<QuickJSWASMModule>

Source

packages/quickjs-emscripten/src/variants.ts:25


newQuickJSWASMModuleFromVariant()

newQuickJSWASMModuleFromVariant(variantOrPromise): Promise<QuickJSWASMModule>

Create a new, completely isolated WebAssembly module containing the QuickJS library. See the documentation on QuickJSWASMModule.

Note that there is a hard limit on the number of WebAssembly modules in older versions of v8: https://bugs.chromium.org/p/v8/issues/detail?id=12076

Parameters

variantOrPromise: PromisedDefault<QuickJSSyncVariant>

A QuickJSSyncVariant to construct the WebAssembly module.

Returns

Promise<QuickJSWASMModule>

Example

const quickjs = new newQuickJSWASMModuleFromVariant(
  import('@jitl/quickjs-browser-release-sync-wasm')
)

Source

packages/quickjs-emscripten-core/dist/index.d.ts:1495


newVariant()

newVariant<T>(baseVariant, options): T

Create a new variant by overriding how Emscripten obtains the WebAssembly module. This may be necessary in Cloudflare Workers, which can't compile WebAssembly modules from binary data.

Type parameters

T extends QuickJSVariant

Parameters

baseVariant: T

options: CustomizeVariantOptions

Returns

T

Source

packages/quickjs-emscripten-core/dist/index.d.ts:1575


shouldInterruptAfterDeadline()

shouldInterruptAfterDeadline(deadline): InterruptHandler

Returns an interrupt handler that interrupts Javascript execution after a deadline time.

Parameters

deadline: number | Date

Interrupt execution if it's still running after this time. Number values are compared against Date.now()

Returns

InterruptHandler

Source

packages/quickjs-emscripten-core/dist/index.d.ts:1583


Generated using typedoc-plugin-markdown and TypeDoc