1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
[quickjs-emscripten](../README.md) / [Exports](../modules.md) / QuickJSAsyncWASMModule
# Class: QuickJSAsyncWASMModule
Asyncified version of [QuickJSWASMModule](QuickJSWASMModule.md).
Due to limitations of Emscripten's ASYNCIFY process, only a single async
function call can happen at a time across the entire WebAssembly module.
That means that all runtimes, contexts, functions, etc created inside this
WebAssembly are limited to a single concurrent async action.
**Multiple concurrent async actions is an error.**
To allow for multiple concurrent async actions, you must create multiple WebAssembly
modules.
## Hierarchy
- [`QuickJSWASMModule`](QuickJSWASMModule.md)
↳ **`QuickJSAsyncWASMModule`**
## Table of contents
### Methods
- [evalCode](QuickJSAsyncWASMModule.md#evalcode)
- [evalCodeAsync](QuickJSAsyncWASMModule.md#evalcodeasync)
- [newContext](QuickJSAsyncWASMModule.md#newcontext)
- [newRuntime](QuickJSAsyncWASMModule.md#newruntime)
## Methods
### evalCode
▸ **evalCode**(): `never`
Synchronous evalCode is not supported.
#### Returns
`never`
#### Overrides
[QuickJSWASMModule](QuickJSWASMModule.md).[evalCode](QuickJSWASMModule.md#evalcode)
#### Defined in
[ts/module-asyncify.ts:81](https://github.com/justjake/quickjs-emscripten/blob/main/ts/module-asyncify.ts#L81)
___
### evalCodeAsync
▸ **evalCodeAsync**(`code`, `options`): `Promise`<`unknown`\>
One-off evaluate code without needing to create a [[QuickJSRuntimeAsync]] or
[[QuickJSContextSync]] explicitly.
This version allows for asynchronous Ecmascript module loading.
Note that only a single async action can occur at a time inside the entire WebAssembly module.
**Multiple concurrent async actions is an error.**
See the documentation for [QuickJSWASMModule.evalCode](QuickJSWASMModule.md#evalcode) for more details.
#### Parameters
| Name | Type |
| :------ | :------ |
| `code` | `string` |
| `options` | [`ModuleEvalOptions`](../interfaces/ModuleEvalOptions.md) |
#### Returns
`Promise`<`unknown`\>
#### Defined in
[ts/module-asyncify.ts:96](https://github.com/justjake/quickjs-emscripten/blob/main/ts/module-asyncify.ts#L96)
___
### newContext
▸ **newContext**(`options?`): [`QuickJSAsyncContext`](QuickJSAsyncContext.md)
A simplified API to create a new [QuickJSRuntime](QuickJSRuntime.md) and a
[QuickJSContext](QuickJSContext.md) inside that runtime at the same time. The runtime will
be disposed when the context is disposed.
#### Parameters
| Name | Type |
| :------ | :------ |
| `options` | [`ContextOptions`](../interfaces/ContextOptions.md) |
#### Returns
[`QuickJSAsyncContext`](QuickJSAsyncContext.md)
#### Overrides
[QuickJSWASMModule](QuickJSWASMModule.md).[newContext](QuickJSWASMModule.md#newcontext)
#### Defined in
[ts/module-asyncify.ts:72](https://github.com/justjake/quickjs-emscripten/blob/main/ts/module-asyncify.ts#L72)
___
### newRuntime
▸ **newRuntime**(`options?`): [`QuickJSAsyncRuntime`](QuickJSAsyncRuntime.md)
Create a new async runtime inside this WebAssembly module. All runtimes inside a
module are limited to a single async call at a time. For multiple
concurrent async actions, create multiple WebAssembly modules.
#### Parameters
| Name | Type |
| :------ | :------ |
| `options` | [`AsyncRuntimeOptions`](../interfaces/AsyncRuntimeOptions.md) |
#### Returns
[`QuickJSAsyncRuntime`](QuickJSAsyncRuntime.md)
#### Overrides
[QuickJSWASMModule](QuickJSWASMModule.md).[newRuntime](QuickJSWASMModule.md#newruntime)
#### Defined in
[ts/module-asyncify.ts:46](https://github.com/justjake/quickjs-emscripten/blob/main/ts/module-asyncify.ts#L46)
|