quickjs-emscripten • quickjs-emscripten • Readme | Exports
quickjs-emscripten / quickjs-emscripten
- Namespaces
- Classes
- Interfaces
- Type Aliases
- AsyncFunctionImplementation
- BorrowedHeapCharPointer
- DisposableArray<T>
- DisposableResult<S, F>
- EitherFFI
- EitherModule
- ExecutePendingJobsResult
- InterruptHandler
- Intrinsics
- JSBorrowedCharPointer
- JSContextPointer
- JSContextPointerPointer
- JSModuleDefPointer
- JSModuleLoadFailure
- JSModuleLoadResult
- JSModuleLoadSuccess
- JSModuleNormalizeFailure
- JSModuleNormalizeResult
- JSModuleNormalizeSuccess
- JSPromiseState
- JSPromiseStateEnum
- JSRuntimePointer
- JSValue
- JSValueConst
- JSValueConstPointer
- JSValueConstPointerPointer
- JSValuePointer
- JSValuePointerPointer
- JSValuePointerPointerPointer
- JSVoidPointer
- OrLoader<T>
- OwnedHeapCharPointer
- PromiseExecutor<ResolveT, RejectT>
- PromisedDefault<T>
- QTS_C_To_HostCallbackFuncPointer
- QTS_C_To_HostInterruptFuncPointer
- QTS_C_To_HostLoadModuleFuncPointer
- QuickJSHandle
- QuickJSPropertyKey
- QuickJSVariant
- StaticJSValue
- SuccessOrFail<S, F>
- UInt32Pointer
- VmCallResult<VmHandle>
- VmFunctionImplementation<VmHandle>
- Variables
- DEBUG_ASYNC
- @jitl/quickjs-wasmfile-debug-asyncify
- DEBUG_SYNC
- @jitl/quickjs-wasmfile-debug-sync
- DefaultIntrinsics
- DisposableResult
- EvalFlags
- GetOwnPropertyNamesFlags
- IntrinsicsFlags
- IsEqualOp
- JSPromiseStateEnum
- RELEASE_ASYNC
- @jitl/quickjs-wasmfile-release-asyncify
- RELEASE_SYNC
- @jitl/quickjs-wasmfile-release-sync
- Functions
- assertSync()
- createDisposableArray()
- getQuickJS()
- getQuickJSSync()
- isFail()
- isSuccess()
- memoizePromiseFactory()
- newAsyncContext()
- newAsyncRuntime()
- newQuickJSAsyncWASMModule()
- newQuickJSAsyncWASMModuleFromVariant()
- newQuickJSWASMModule()
- newQuickJSWASMModuleFromVariant()
- newVariant()
- setDebugMode()
- shouldInterruptAfterDeadline()
- DisposableFail
- DisposableSuccess
- Lifetime
- QuickJSAsyncContext
- QuickJSAsyncRuntime
- QuickJSAsyncWASMModule
- QuickJSContext
- QuickJSDeferredPromise
- QuickJSRuntime
- QuickJSWASMModule
- Scope
- StaticLifetime
- TestQuickJSWASMModule
- UsingDisposable
- WeakLifetime
- AsyncRuntimeOptions
- ContextEvalOptions
- ContextOptions
- CustomizeVariantOptions
- Disposable
- EmscriptenModule
- EmscriptenModuleLoader
- EmscriptenModuleLoaderOptions
- JSModuleLoader
- JSModuleLoaderAsync
- JSModuleNormalizer
- JSModuleNormalizerAsync
- JSPromiseStateFulfilled
- JSPromiseStatePending
- JSPromiseStateRejected
- LowLevelJavascriptVm
- ModuleEvalOptions
- QuickJSAsyncEmscriptenModule
- QuickJSAsyncFFI
- QuickJSAsyncVariant
- QuickJSEmscriptenModule
- QuickJSFFI
- QuickJSSyncVariant
- RuntimeOptions
- RuntimeOptionsBase
- SourceMapData
- VmPropertyDescriptor
AsyncFunctionImplementation: (
this
, ...args
) =>Promise
<QuickJSHandle
|VmCallResult
<QuickJSHandle
> |void
>
• this: QuickJSHandle
• ...args: QuickJSHandle
[]
Promise
<QuickJSHandle
| VmCallResult
<QuickJSHandle
> | void
>
packages/quickjs-emscripten-core/src/context-asyncify.ts:18
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.
packages/quickjs-ffi-types/dist/index.d.ts:70
DisposableArray<
T
>:T
[] &Disposable
An Array
that also implements Disposable:
- Considered Disposable#alive if any of its elements are
alive
. - When Disposable#disposed, it will dispose of all its elements that are
alive
.
• T
packages/quickjs-emscripten-core/src/lifetime.ts:354
DisposableResult<
S
,F
>:DisposableSuccess
<S
> |DisposableFail
<F
>
• S
• F
packages/quickjs-emscripten-core/src/lifetime.ts:478
EitherFFI:
QuickJSFFI
|QuickJSAsyncFFI
packages/quickjs-ffi-types/dist/index.d.ts:538
EitherModule:
QuickJSEmscriptenModule
|QuickJSAsyncEmscriptenModule
packages/quickjs-ffi-types/dist/index.d.ts:332
ExecutePendingJobsResult:
DisposableResult
<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.
packages/quickjs-emscripten-core/src/runtime.ts:35
InterruptHandler: (
runtime
) =>boolean
|undefined
|void
Callback called regularly while the VM executes code. Determines if a VM's execution should be interrupted.
• runtime: QuickJSRuntime
boolean
| undefined
| void
true
to interrupt JS execution inside the VM.
false
or undefined
to continue JS execution inside the VM.
packages/quickjs-emscripten-core/src/runtime.ts:27
Intrinsics:
Object
Language features that can be enabled or disabled in a QuickJSContext.
BaseObjects?:
boolean
BigDecimal?:
boolean
BigFloat?:
boolean
BigInt?:
boolean
BignumExt?:
boolean
Date?:
boolean
Eval?:
boolean
JSON?:
boolean
MapSet?:
boolean
OperatorOverloading?:
boolean
Promise?:
boolean
Proxy?:
boolean
RegExp?:
boolean
RegExpCompiler?:
boolean
StringNormalize?:
boolean
TypedArrays?:
boolean
packages/quickjs-emscripten-core/src/types.ts:146
JSBorrowedCharPointer:
Pointer
<"js const char"
>
Used internally for Javascript-to-C calls that may contain strings too large for the Emscripten stack.
packages/quickjs-ffi-types/dist/index.d.ts:80
JSContextPointer:
Pointer
<"JSContext"
>
JSContext*
.
packages/quickjs-ffi-types/dist/index.d.ts:20
JSContextPointerPointer:
Pointer
<"JSContext"
>
JSContext**
. Used internally for execute pending jobs.
packages/quickjs-ffi-types/dist/index.d.ts:24
JSModuleDefPointer:
Pointer
<"JSModuleDef"
>
JSModuleDef*
.
packages/quickjs-ffi-types/dist/index.d.ts:28
JSModuleLoadFailure:
Error
|QuickJSHandle
packages/quickjs-emscripten-core/src/types.ts:69
JSModuleLoadResult:
JSModuleLoadSuccess
|SuccessOrFail
<JSModuleLoadSuccess
,JSModuleLoadFailure
>
packages/quickjs-emscripten-core/src/types.ts:70
JSModuleLoadSuccess:
string
packages/quickjs-emscripten-core/src/types.ts:68
JSModuleNormalizeFailure:
Error
|QuickJSHandle
packages/quickjs-emscripten-core/src/types.ts:87
JSModuleNormalizeResult:
JSModuleNormalizeSuccess
|SuccessOrFail
<JSModuleNormalizeSuccess
,JSModuleNormalizeFailure
>
packages/quickjs-emscripten-core/src/types.ts:88
JSModuleNormalizeSuccess:
string
packages/quickjs-emscripten-core/src/types.ts:86
JSPromiseState:
JSPromiseStatePending
|JSPromiseStateFulfilled
|JSPromiseStateRejected
A promise state inside QuickJS, which can be pending, fulfilled, or rejected. You can unwrap a JSPromiseState with QuickJSContext#unwrapResult.
packages/quickjs-emscripten-core/src/deferred-promise.ts:11
JSPromiseStateEnum:
Brand
<typeofJSPromiseStateEnum
[keyof typeofJSPromiseStateEnum
],"JSPromiseStateEnum"
>
State of a promise.
packages/quickjs-ffi-types/dist/index.d.ts:145
JSRuntimePointer:
Pointer
<"JSRuntime"
>
JSRuntime*
.
packages/quickjs-ffi-types/dist/index.d.ts:16
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 free
d.
You can do so from Javascript by calling the .dispose() method.
packages/quickjs-emscripten-core/src/types.ts:43
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.
packages/quickjs-emscripten-core/src/types.ts:26
JSValueConstPointer:
Pointer
<"JSValueConst"
>
`JSValueConst* See JSValueConst and StaticJSValue.
packages/quickjs-ffi-types/dist/index.d.ts:38
JSValueConstPointerPointer:
Pointer
<"JSValueConst[]"
>
Used internally for Javascript-to-C function calls.
packages/quickjs-ffi-types/dist/index.d.ts:50
JSValuePointer:
Pointer
<"JSValue"
>
JSValue*
.
See JSValue.
packages/quickjs-ffi-types/dist/index.d.ts:33
JSValuePointerPointer:
Pointer
<"JSValue[]"
>
Used internally for Javascript-to-C function calls.
packages/quickjs-ffi-types/dist/index.d.ts:42
JSValuePointerPointerPointer:
Pointer
<"*JSValue[]"
>
Used internally for Javascript-to-C function calls.
packages/quickjs-ffi-types/dist/index.d.ts:46
JSVoidPointer:
Pointer
<any
>
Opaque pointer that was allocated by js_malloc.
packages/quickjs-ffi-types/dist/index.d.ts:84
OrLoader<
T
>:T
| () =>Promise
<T
>
• T
packages/quickjs-emscripten-core/src/from-variant.ts:117
OwnedHeapCharPointer:
Pointer
<"char"
>
Used internally for Javascript-to-C calls that may contain strings too large for the Emscripten stack.
packages/quickjs-ffi-types/dist/index.d.ts:75
PromiseExecutor<
ResolveT
,RejectT
>: (resolve
,reject
) =>void
• ResolveT
• RejectT
• resolve: (value
) => void
• reject: (reason
) => void
void
packages/quickjs-emscripten-core/src/types.ts:333
PromisedDefault<
T
>:T
|Promise
<T
> |Promise
<Object
> |Promise
<Object
>
• T
packages/quickjs-emscripten-core/src/from-variant.ts:17
QTS_C_To_HostCallbackFuncPointer:
Pointer
<"C_To_HostCallbackFunc"
>
Used internally for C-to-Javascript function calls.
packages/quickjs-ffi-types/dist/index.d.ts:57
QTS_C_To_HostInterruptFuncPointer:
Pointer
<"C_To_HostInterruptFunc"
>
Used internally for C-to-Javascript interrupt handlers.
packages/quickjs-ffi-types/dist/index.d.ts:61
QTS_C_To_HostLoadModuleFuncPointer:
Pointer
<"C_To_HostLoadModuleFunc"
>
Used internally for C-to-Javascript module loading.
packages/quickjs-ffi-types/dist/index.d.ts:65
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.
packages/quickjs-emscripten-core/src/types.ts:53
QuickJSPropertyKey:
number
|string
|QuickJSHandle
Property key for getting or setting a property on a handle with QuickJSContext#getProp, QuickJSContext#setProp, or QuickJSContext#defineProp.
packages/quickjs-emscripten-core/src/context.ts:68
QuickJSVariant:
QuickJSSyncVariant
|QuickJSAsyncVariant
packages/quickjs-ffi-types/dist/index.d.ts:537
StaticJSValue:
Lifetime
<JSValueConstPointer
,JSValueConstPointer
,QuickJSRuntime
>
A QuickJSHandle to a constant that will never change, and does not need to be disposed.
packages/quickjs-emscripten-core/src/types.ts:14
SuccessOrFail<
S
,F
>:Object
|Object
Used as an optional.
{ value: S } | { error: E }
.
• S
• F
packages/quickjs-emscripten-core/src/vm-interface.ts:5
UInt32Pointer:
Pointer
<"uint32_t"
>
packages/quickjs-ffi-types/dist/index.d.ts:85
VmCallResult<
VmHandle
>:SuccessOrFail
<VmHandle
,VmHandle
>
Used as an optional for results of a Vm call.
{ value: VmHandle } | { error: VmHandle }
.
• VmHandle
packages/quickjs-emscripten-core/src/vm-interface.ts:26
VmFunctionImplementation<
VmHandle
>: (this
, ...args
) =>VmHandle
|VmCallResult
<VmHandle
> |void
• 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.
• this: VmHandle
• ...args: VmHandle
[]
VmHandle
| VmCallResult
<VmHandle
> | void
packages/quickjs-emscripten-core/src/vm-interface.ts:40
const
DEBUG_ASYNC:QuickJSAsyncVariant
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-02-14+36911f0d vendored to quickjs-emscripten on 2024-06-15. |
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 |
packages/variant-quickjs-wasmfile-debug-asyncify/dist/index.d.ts:18
const
DEBUG_SYNC:QuickJSSyncVariant
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-02-14+36911f0d vendored to quickjs-emscripten on 2024-06-15. |
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 |
packages/variant-quickjs-wasmfile-debug-sync/dist/index.d.ts:18
const
DefaultIntrinsics:Readonly
<Object
>
The default Intrinsics language features enabled in a QuickJSContext.
readonly
BaseObjects:true
=true
readonly
Date:true
=true
readonly
Eval:true
=true
readonly
JSON:true
=true
readonly
MapSet:true
=true
readonly
Promise:true
=true
readonly
Proxy:true
=true
readonly
RegExp:true
=true
readonly
StringNormalize:true
=true
readonly
TypedArrays:true
=true
packages/quickjs-emscripten-core/src/types.ts:173
DisposableResult: typeof
AbstractDisposableResult
packages/quickjs-emscripten-core/src/lifetime.ts:478
EvalFlags:
Object
Bitfield options for JS_Eval() C function.
readonly
JS_EVAL_FLAG_BACKTRACE_BARRIER:number
don't include the stack frames before this eval in the Error() backtraces
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().
readonly
JS_EVAL_FLAG_STRICT:number
force 'strict' mode
readonly
JS_EVAL_FLAG_STRIP:number
force 'strip' mode
readonly
JS_EVAL_TYPE_DIRECT:number
direct call (internal use)
readonly
JS_EVAL_TYPE_GLOBAL:number
global code (default)
readonly
JS_EVAL_TYPE_INDIRECT:number
indirect call (internal use)
readonly
JS_EVAL_TYPE_MASK:number
readonly
JS_EVAL_TYPE_MODULE:number
module code
packages/quickjs-ffi-types/dist/index.d.ts:94
GetOwnPropertyNamesFlags:
Object
Bitfield options for QTS_GetOwnPropertyNames
JS_GPN_ENUM_ONLY:
number
JS_GPN_PRIVATE_MASK:
number
JS_GPN_SET_ENUM:
number
JS_GPN_STRING_MASK:
number
JS_GPN_SYMBOL_MASK:
number
QTS_GPN_NUMBER_MASK:
number
QTS_STANDARD_COMPLIANT_NUMBER:
number
packages/quickjs-ffi-types/dist/index.d.ts:154
IntrinsicsFlags:
Object
Bitfield options for QTS_NewContext intrinsics
readonly
BaseObjects:number
readonly
BigDecimal:number
readonly
BigFloat:number
readonly
BigInt:number
readonly
BignumExt:number
readonly
Date:number
readonly
Eval:number
readonly
JSON:number
readonly
MapSet:number
readonly
OperatorOverloading:number
readonly
Promise:number
readonly
Proxy:number
readonly
RegExp:number
readonly
RegExpCompiler:number
readonly
StringNormalize:number
readonly
TypedArrays:number
packages/quickjs-ffi-types/dist/index.d.ts:122
IsEqualOp:
Object
IsSameValue:
IsEqualOp
IsSameValueZero:
IsEqualOp
IsStrictlyEqual:
IsEqualOp
packages/quickjs-ffi-types/dist/index.d.ts:168
JSPromiseStateEnum:
Object
readonly
Fulfilled:1
readonly
Pending:0
readonly
Rejected:2
packages/quickjs-ffi-types/dist/index.d.ts:145
const
RELEASE_ASYNC:QuickJSAsyncVariant
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-02-14+36911f0d vendored to quickjs-emscripten on 2024-06-15. |
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 |
packages/variant-quickjs-wasmfile-release-asyncify/dist/index.d.ts:18
const
RELEASE_SYNC:QuickJSSyncVariant
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-02-14+36911f0d vendored to quickjs-emscripten on 2024-06-15. |
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 |
packages/variant-quickjs-wasmfile-release-sync/dist/index.d.ts:18
assertSync<
Args
,R
>(fn
): (...args
) =>R
• Args extends any
[]
• R
• fn: (...args
) => R
Function
• ...args:
Args
R
packages/quickjs-ffi-types/dist/index.d.ts:90
createDisposableArray<
T
>(items
?):DisposableArray
<T
>
Create an array that also implements Disposable.
• T extends Disposable
• items?: Iterable
<T
>
packages/quickjs-emscripten-core/src/lifetime.ts:359
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:
Promise
<QuickJSWASMModule
>
packages/quickjs-emscripten/src/mod.ts:28
getQuickJSSync():
QuickJSWASMModule
Provides synchronous access to the shared QuickJSWASMModule instance returned by getQuickJS, as long as least once.
If called before getQuickJS
resolves.
packages/quickjs-emscripten/src/mod.ts:41
isFail<
S
,F
>(successOrFail
):successOrFail is Object
• S
• F
• successOrFail: SuccessOrFail
<S
, F
>
successOrFail is Object
packages/quickjs-emscripten-core/src/vm-interface.ts:18
isSuccess<
S
,F
>(successOrFail
):successOrFail is Object
• S
• F
• successOrFail: SuccessOrFail
<S
, F
>
successOrFail is Object
packages/quickjs-emscripten-core/src/vm-interface.ts:14
memoizePromiseFactory<
T
>(fn
): () =>Promise
<T
>
Helper intended to memoize the creation of a WebAssembly module.
const getDebugModule = memoizePromiseFactory(() => newQuickJSWASMModule(DEBUG_SYNC))
• T
• fn: () => Promise
<T
>
Function
Promise
<T
>
packages/quickjs-emscripten-core/src/from-variant.ts:100
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
• options?: ContextOptions
Promise
<QuickJSAsyncContext
>
packages/quickjs-emscripten/src/mod.ts:76
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
• options?: AsyncRuntimeOptions
Promise
<QuickJSAsyncRuntime
>
packages/quickjs-emscripten/src/mod.ts:59
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
• variantOrPromise: PromisedDefault
<QuickJSAsyncVariant
>= RELEASE_ASYNC
Optionally, pass a QuickJSAsyncVariant to construct a different WebAssembly module.
Promise
<QuickJSAsyncWASMModule
>
packages/quickjs-emscripten/src/variants.ts:47
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
• variantOrPromise: PromisedDefault
<QuickJSAsyncVariant
>
A QuickJSAsyncVariant to construct the WebAssembly module.
Promise
<QuickJSAsyncWASMModule
>
const quickjs = new newQuickJSAsyncWASMModuleFromVariant(
import('@jitl/quickjs-browser-debug-asyncify-wasm')
)
packages/quickjs-emscripten-core/src/from-variant.ts:76
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
• variantOrPromise: PromisedDefault
<QuickJSSyncVariant
>= RELEASE_SYNC
Optionally, pass a QuickJSSyncVariant to construct a different WebAssembly module.
Promise
<QuickJSWASMModule
>
packages/quickjs-emscripten/src/variants.ts:25
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
• variantOrPromise: PromisedDefault
<QuickJSSyncVariant
>
A QuickJSSyncVariant to construct the WebAssembly module.
Promise
<QuickJSWASMModule
>
const quickjs = new newQuickJSWASMModuleFromVariant(
import('@jitl/quickjs-browser-release-sync-wasm')
)
packages/quickjs-emscripten-core/src/from-variant.ts:38
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.
• T extends QuickJSVariant
• baseVariant: T
• options: CustomizeVariantOptions
T
packages/quickjs-emscripten-core/src/from-variant.ts:162
setDebugMode(
enabled
):void
Enable (or disable) debug logging and object creation tracking globally. This setting is inherited by newly created QuickJSRuntime instances. To get debug logging in the WebAssembly module, you need to use a debug build variant. See the quickjs-emscripten-core README for more about build variants.
• enabled: boolean
= true
void
packages/quickjs-emscripten-core/src/debug.ts:13
shouldInterruptAfterDeadline(
deadline
):InterruptHandler
Returns an interrupt handler that interrupts Javascript execution after a deadline time.
• deadline: number
| Date
Interrupt execution if it's still running after this time.
Number values are compared against Date.now()
packages/quickjs-emscripten-core/src/interrupt-helpers.ts:9
Generated using typedoc-plugin-markdown and TypeDoc