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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
|
[quickjs-emscripten](README.md) / Exports
# quickjs-emscripten
## Table of contents
### Namespaces
- [errors](modules/errors.md)
### Classes
- [Lifetime](classes/Lifetime.md)
- [QuickJSAsyncContext](classes/QuickJSAsyncContext.md)
- [QuickJSAsyncRuntime](classes/QuickJSAsyncRuntime.md)
- [QuickJSAsyncWASMModule](classes/QuickJSAsyncWASMModule.md)
- [QuickJSContext](classes/QuickJSContext.md)
- [QuickJSDeferredPromise](classes/QuickJSDeferredPromise.md)
- [QuickJSRuntime](classes/QuickJSRuntime.md)
- [QuickJSWASMModule](classes/QuickJSWASMModule.md)
- [Scope](classes/Scope.md)
- [StaticLifetime](classes/StaticLifetime.md)
- [TestQuickJSWASMModule](classes/TestQuickJSWASMModule.md)
- [WeakLifetime](classes/WeakLifetime.md)
### Interfaces
- [AsyncBuildVariant](interfaces/AsyncBuildVariant.md)
- [AsyncRuntimeOptions](interfaces/AsyncRuntimeOptions.md)
- [ContextEvalOptions](interfaces/ContextEvalOptions.md)
- [ContextOptions](interfaces/ContextOptions.md)
- [Disposable](interfaces/Disposable.md)
- [JSModuleLoader](interfaces/JSModuleLoader.md)
- [JSModuleLoaderAsync](interfaces/JSModuleLoaderAsync.md)
- [JSModuleNormalizer](interfaces/JSModuleNormalizer.md)
- [JSModuleNormalizerAsync](interfaces/JSModuleNormalizerAsync.md)
- [LowLevelJavascriptVm](interfaces/LowLevelJavascriptVm.md)
- [ModuleEvalOptions](interfaces/ModuleEvalOptions.md)
- [RuntimeOptions](interfaces/RuntimeOptions.md)
- [RuntimeOptionsBase](interfaces/RuntimeOptionsBase.md)
- [SyncBuildVariant](interfaces/SyncBuildVariant.md)
- [VmPropertyDescriptor](interfaces/VmPropertyDescriptor.md)
### Type aliases
- [AsyncFunctionImplementation](modules.md#asyncfunctionimplementation)
- [ExecutePendingJobsResult](modules.md#executependingjobsresult)
- [InterruptHandler](modules.md#interrupthandler)
- [JSModuleLoadFailure](modules.md#jsmoduleloadfailure)
- [JSModuleLoadResult](modules.md#jsmoduleloadresult)
- [JSModuleLoadSuccess](modules.md#jsmoduleloadsuccess)
- [JSModuleNormalizeFailure](modules.md#jsmodulenormalizefailure)
- [JSModuleNormalizeResult](modules.md#jsmodulenormalizeresult)
- [JSModuleNormalizeSuccess](modules.md#jsmodulenormalizesuccess)
- [JSValue](modules.md#jsvalue)
- [JSValueConst](modules.md#jsvalueconst)
- [PromiseExecutor](modules.md#promiseexecutor)
- [QuickJSHandle](modules.md#quickjshandle)
- [QuickJSPropertyKey](modules.md#quickjspropertykey)
- [StaticJSValue](modules.md#staticjsvalue)
- [SuccessOrFail](modules.md#successorfail)
- [VmCallResult](modules.md#vmcallresult)
- [VmFunctionImplementation](modules.md#vmfunctionimplementation)
### Variables
- [DEBUG\_ASYNC](modules.md#debug_async)
- [DEBUG\_SYNC](modules.md#debug_sync)
- [RELEASE\_ASYNC](modules.md#release_async)
- [RELEASE\_SYNC](modules.md#release_sync)
### Functions
- [getQuickJS](modules.md#getquickjs)
- [getQuickJSSync](modules.md#getquickjssync)
- [isFail](modules.md#isfail)
- [isSuccess](modules.md#issuccess)
- [newAsyncContext](modules.md#newasynccontext)
- [newAsyncRuntime](modules.md#newasyncruntime)
- [newQuickJSAsyncWASMModule](modules.md#newquickjsasyncwasmmodule)
- [newQuickJSWASMModule](modules.md#newquickjswasmmodule)
- [shouldInterruptAfterDeadline](modules.md#shouldinterruptafterdeadline)
## Type aliases
### AsyncFunctionImplementation
Ƭ **AsyncFunctionImplementation**: (`this`: [`QuickJSHandle`](modules.md#quickjshandle), ...`args`: [`QuickJSHandle`](modules.md#quickjshandle)[]) => `Promise`<[`QuickJSHandle`](modules.md#quickjshandle) \| [`VmCallResult`](modules.md#vmcallresult)<[`QuickJSHandle`](modules.md#quickjshandle)\> \| `void`\>
#### Type declaration
▸ (`this`, ...`args`): `Promise`<[`QuickJSHandle`](modules.md#quickjshandle) \| [`VmCallResult`](modules.md#vmcallresult)<[`QuickJSHandle`](modules.md#quickjshandle)\> \| `void`\>
##### Parameters
| Name | Type |
| :------ | :------ |
| `this` | [`QuickJSHandle`](modules.md#quickjshandle) |
| `...args` | [`QuickJSHandle`](modules.md#quickjshandle)[] |
##### Returns
`Promise`<[`QuickJSHandle`](modules.md#quickjshandle) \| [`VmCallResult`](modules.md#vmcallresult)<[`QuickJSHandle`](modules.md#quickjshandle)\> \| `void`\>
#### Defined in
[ts/context-asyncify.ts:12](https://github.com/justjake/quickjs-emscripten/blob/main/ts/context-asyncify.ts#L12)
___
### ExecutePendingJobsResult
Ƭ **ExecutePendingJobsResult**: [`SuccessOrFail`](modules.md#successorfail)<`number`, [`QuickJSHandle`](modules.md#quickjshandle) & { `context`: [`QuickJSContext`](classes/QuickJSContext.md) }\>
Used as an optional for the results of executing pendingJobs.
On success, `value` contains the number of async jobs executed
by the runtime.
**`source`**
#### Defined in
[ts/runtime.ts:41](https://github.com/justjake/quickjs-emscripten/blob/main/ts/runtime.ts#L41)
___
### InterruptHandler
Ƭ **InterruptHandler**: (`runtime`: [`QuickJSRuntime`](classes/QuickJSRuntime.md)) => `boolean` \| `undefined`
#### Type declaration
▸ (`runtime`): `boolean` \| `undefined`
Callback called regularly while the VM executes code.
Determines if a VM's execution should be interrupted.
##### Parameters
| Name | Type |
| :------ | :------ |
| `runtime` | [`QuickJSRuntime`](classes/QuickJSRuntime.md) |
##### Returns
`boolean` \| `undefined`
`true` to interrupt JS execution inside the VM.
#### Defined in
[ts/runtime.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/ts/runtime.ts#L33)
___
### JSModuleLoadFailure
Ƭ **JSModuleLoadFailure**: `Error` \| [`QuickJSHandle`](modules.md#quickjshandle)
#### Defined in
[ts/types.ts:69](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L69)
___
### JSModuleLoadResult
Ƭ **JSModuleLoadResult**: [`JSModuleLoadSuccess`](modules.md#jsmoduleloadsuccess) \| [`SuccessOrFail`](modules.md#successorfail)<[`JSModuleLoadSuccess`](modules.md#jsmoduleloadsuccess), [`JSModuleLoadFailure`](modules.md#jsmoduleloadfailure)\>
#### Defined in
[ts/types.ts:70](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L70)
___
### JSModuleLoadSuccess
Ƭ **JSModuleLoadSuccess**: `string`
#### Defined in
[ts/types.ts:68](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L68)
___
### JSModuleNormalizeFailure
Ƭ **JSModuleNormalizeFailure**: `Error` \| [`QuickJSHandle`](modules.md#quickjshandle)
#### Defined in
[ts/types.ts:86](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L86)
___
### JSModuleNormalizeResult
Ƭ **JSModuleNormalizeResult**: [`JSModuleNormalizeSuccess`](modules.md#jsmodulenormalizesuccess) \| [`SuccessOrFail`](modules.md#successorfail)<[`JSModuleNormalizeSuccess`](modules.md#jsmodulenormalizesuccess), [`JSModuleNormalizeFailure`](modules.md#jsmodulenormalizefailure)\>
#### Defined in
[ts/types.ts:87](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L87)
___
### JSModuleNormalizeSuccess
Ƭ **JSModuleNormalizeSuccess**: `string`
#### Defined in
[ts/types.ts:85](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L85)
___
### JSValue
Ƭ **JSValue**: [`Lifetime`](classes/Lifetime.md)<`JSValuePointer`, `JSValuePointer`, [`QuickJSRuntime`](classes/QuickJSRuntime.md)\>
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.
#### Defined in
[ts/types.ts:44](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L44)
___
### JSValueConst
Ƭ **JSValueConst**: [`Lifetime`](classes/Lifetime.md)<`JSValueConstPointer`, `JSValuePointer`, [`QuickJSRuntime`](classes/QuickJSRuntime.md)\>
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.
#### Defined in
[ts/types.ts:27](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L27)
___
### PromiseExecutor
Ƭ **PromiseExecutor**<`ResolveT`, `RejectT`\>: (`resolve`: (`value`: `ResolveT` \| `PromiseLike`<`ResolveT`\>) => `void`, `reject`: (`reason`: `RejectT`) => `void`) => `void`
#### Type parameters
| Name |
| :------ |
| `ResolveT` |
| `RejectT` |
#### Type declaration
▸ (`resolve`, `reject`): `void`
##### Parameters
| Name | Type |
| :------ | :------ |
| `resolve` | (`value`: `ResolveT` \| `PromiseLike`<`ResolveT`\>) => `void` |
| `reject` | (`reason`: `RejectT`) => `void` |
##### Returns
`void`
#### Defined in
[ts/types.ts:236](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L236)
___
### QuickJSHandle
Ƭ **QuickJSHandle**: [`StaticJSValue`](modules.md#staticjsvalue) \| [`JSValue`](modules.md#jsvalue) \| [`JSValueConst`](modules.md#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.
#### Defined in
[ts/types.ts:53](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L53)
___
### QuickJSPropertyKey
Ƭ **QuickJSPropertyKey**: `number` \| `string` \| [`QuickJSHandle`](modules.md#quickjshandle)
Property key for getting or setting a property on a handle with
[QuickJSContext.getProp](classes/QuickJSContext.md#getprop), [QuickJSContext.setProp](classes/QuickJSContext.md#setprop), or [QuickJSContext.defineProp](classes/QuickJSContext.md#defineprop).
#### Defined in
[ts/context.ts:41](https://github.com/justjake/quickjs-emscripten/blob/main/ts/context.ts#L41)
___
### StaticJSValue
Ƭ **StaticJSValue**: [`Lifetime`](classes/Lifetime.md)<`JSValueConstPointer`, `JSValueConstPointer`, [`QuickJSRuntime`](classes/QuickJSRuntime.md)\>
A QuickJSHandle to a constant that will never change, and does not need to
be disposed.
#### Defined in
[ts/types.ts:15](https://github.com/justjake/quickjs-emscripten/blob/main/ts/types.ts#L15)
___
### SuccessOrFail
Ƭ **SuccessOrFail**<`S`, `F`\>: { `error?`: `undefined` ; `value`: `S` } \| { `error`: `F` }
Used as an optional.
`{ value: S } | { error: E }`.
#### Type parameters
| Name |
| :------ |
| `S` |
| `F` |
#### Defined in
[ts/vm-interface.ts:5](https://github.com/justjake/quickjs-emscripten/blob/main/ts/vm-interface.ts#L5)
___
### VmCallResult
Ƭ **VmCallResult**<`VmHandle`\>: [`SuccessOrFail`](modules.md#successorfail)<`VmHandle`, `VmHandle`\>
Used as an optional for results of a Vm call.
`{ value: VmHandle } | { error: VmHandle }`.
#### Type parameters
| Name |
| :------ |
| `VmHandle` |
#### Defined in
[ts/vm-interface.ts:26](https://github.com/justjake/quickjs-emscripten/blob/main/ts/vm-interface.ts#L26)
___
### VmFunctionImplementation
Ƭ **VmFunctionImplementation**<`VmHandle`\>: (`this`: `VmHandle`, ...`args`: `VmHandle`[]) => `VmHandle` \| [`VmCallResult`](modules.md#vmcallresult)<`VmHandle`\> \| `void`
#### Type parameters
| Name |
| :------ |
| `VmHandle` |
#### Type declaration
▸ (`this`, ...`args`): `VmHandle` \| [`VmCallResult`](modules.md#vmcallresult)<`VmHandle`\> \| `void`
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
| Name | Type |
| :------ | :------ |
| `this` | `VmHandle` |
| `...args` | `VmHandle`[] |
##### Returns
`VmHandle` \| [`VmCallResult`](modules.md#vmcallresult)<`VmHandle`\> \| `void`
#### Defined in
[ts/vm-interface.ts:40](https://github.com/justjake/quickjs-emscripten/blob/main/ts/vm-interface.ts#L40)
## Variables
### DEBUG\_ASYNC
• **DEBUG\_ASYNC**: [`AsyncBuildVariant`](interfaces/AsyncBuildVariant.md)
The async debug build variant may or may not have the sanitizer enabled.
It does print a lot of debug logs.
Suggested use case: interactive debugging only.
#### Defined in
[ts/variants.ts:173](https://github.com/justjake/quickjs-emscripten/blob/main/ts/variants.ts#L173)
___
### DEBUG\_SYNC
• **DEBUG\_SYNC**: [`SyncBuildVariant`](interfaces/SyncBuildVariant.md)
This build variant is compiled with `-fsanitize=leak`. It instruments all
memory allocations and when combined with sourcemaps, can present stack trace
locations where memory leaks occur.
See [TestQuickJSWASMModule](classes/TestQuickJSWASMModule.md) which provides access to the leak sanitizer via
[TestQuickJSWASMModule.assertNoMemoryAllocated](classes/TestQuickJSWASMModule.md#assertnomemoryallocated).
The downside is that it's 100-1000x slower than the other variants.
Suggested use case: automated testing, regression testing, and interactive
debugging.
#### Defined in
[ts/variants.ts:139](https://github.com/justjake/quickjs-emscripten/blob/main/ts/variants.ts#L139)
___
### RELEASE\_ASYNC
• **RELEASE\_ASYNC**: [`AsyncBuildVariant`](interfaces/AsyncBuildVariant.md)
This is the default asyncified build variant.
#### Defined in
[ts/variants.ts:188](https://github.com/justjake/quickjs-emscripten/blob/main/ts/variants.ts#L188)
___
### RELEASE\_SYNC
• **RELEASE\_SYNC**: [`SyncBuildVariant`](interfaces/SyncBuildVariant.md)
This is the default (synchronous) build variant.
[getQuickJS](modules.md#getquickjs) returns a memoized instance of this build variant.
#### Defined in
[ts/variants.ts:155](https://github.com/justjake/quickjs-emscripten/blob/main/ts/variants.ts#L155)
## Functions
### getQuickJS
▸ **getQuickJS**(): `Promise`<[`QuickJSWASMModule`](classes/QuickJSWASMModule.md)\>
Get a shared singleton [QuickJSWASMModule](classes/QuickJSWASMModule.md). 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](classes/QuickJSWASMModule.md) via [newQuickJSWASMModule](modules.md#newquickjswasmmodule).
To work with the asyncified version of this library, see these functions:
- [newAsyncRuntime](modules.md#newasyncruntime).
- [newAsyncContext](modules.md#newasynccontext).
- [newQuickJSAsyncWASMModule](modules.md#newquickjsasyncwasmmodule).
#### Returns
`Promise`<[`QuickJSWASMModule`](classes/QuickJSWASMModule.md)\>
#### Defined in
[ts/index.ts:91](https://github.com/justjake/quickjs-emscripten/blob/main/ts/index.ts#L91)
___
### getQuickJSSync
▸ **getQuickJSSync**(): [`QuickJSWASMModule`](classes/QuickJSWASMModule.md)
Provides synchronous access to the shared [QuickJSWASMModule](classes/QuickJSWASMModule.md) instance returned by [getQuickJS](modules.md#getquickjs), as long as
least once.
**`throws`** If called before `getQuickJS` resolves.
#### Returns
[`QuickJSWASMModule`](classes/QuickJSWASMModule.md)
#### Defined in
[ts/index.ts:104](https://github.com/justjake/quickjs-emscripten/blob/main/ts/index.ts#L104)
___
### isFail
▸ **isFail**<`S`, `F`\>(`successOrFail`): successOrFail is Object
#### Type parameters
| Name |
| :------ |
| `S` |
| `F` |
#### Parameters
| Name | Type |
| :------ | :------ |
| `successOrFail` | [`SuccessOrFail`](modules.md#successorfail)<`S`, `F`\> |
#### Returns
successOrFail is Object
#### Defined in
[ts/vm-interface.ts:18](https://github.com/justjake/quickjs-emscripten/blob/main/ts/vm-interface.ts#L18)
___
### isSuccess
▸ **isSuccess**<`S`, `F`\>(`successOrFail`): successOrFail is Object
#### Type parameters
| Name |
| :------ |
| `S` |
| `F` |
#### Parameters
| Name | Type |
| :------ | :------ |
| `successOrFail` | [`SuccessOrFail`](modules.md#successorfail)<`S`, `F`\> |
#### Returns
successOrFail is Object
#### Defined in
[ts/vm-interface.ts:14](https://github.com/justjake/quickjs-emscripten/blob/main/ts/vm-interface.ts#L14)
___
### newAsyncContext
▸ **newAsyncContext**(`options?`): `Promise`<[`QuickJSAsyncContext`](classes/QuickJSAsyncContext.md)\>
Create a new [QuickJSAsyncContext](classes/QuickJSAsyncContext.md) (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
| Name | Type |
| :------ | :------ |
| `options?` | [`ContextOptions`](interfaces/ContextOptions.md) |
#### Returns
`Promise`<[`QuickJSAsyncContext`](classes/QuickJSAsyncContext.md)\>
#### Defined in
[ts/index.ts:139](https://github.com/justjake/quickjs-emscripten/blob/main/ts/index.ts#L139)
___
### newAsyncRuntime
▸ **newAsyncRuntime**(`options?`): `Promise`<[`QuickJSAsyncRuntime`](classes/QuickJSAsyncRuntime.md)\>
Create a new [QuickJSAsyncRuntime](classes/QuickJSAsyncRuntime.md) 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
| Name | Type |
| :------ | :------ |
| `options?` | [`AsyncRuntimeOptions`](interfaces/AsyncRuntimeOptions.md) |
#### Returns
`Promise`<[`QuickJSAsyncRuntime`](classes/QuickJSAsyncRuntime.md)\>
#### Defined in
[ts/index.ts:122](https://github.com/justjake/quickjs-emscripten/blob/main/ts/index.ts#L122)
___
### newQuickJSAsyncWASMModule
▸ **newQuickJSAsyncWASMModule**(`variant?`): `Promise`<[`QuickJSAsyncWASMModule`](classes/QuickJSAsyncWASMModule.md)\>
Create a new, completely isolated WebAssembly module containing a version of the QuickJS library
compiled with Emscripten's [ASYNCIFY](https://emscripten.org/docs/porting/asyncify.html) 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](classes/QuickJSAsyncWASMModule.md), [QuickJSAsyncRuntime](classes/QuickJSAsyncRuntime.md),
and [QuickJSAsyncContext](classes/QuickJSAsyncContext.md).
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
| Name | Type | Default value |
| :------ | :------ | :------ |
| `variant` | [`AsyncBuildVariant`](interfaces/AsyncBuildVariant.md) | `RELEASE_ASYNC` |
#### Returns
`Promise`<[`QuickJSAsyncWASMModule`](classes/QuickJSAsyncWASMModule.md)\>
#### Defined in
[ts/variants.ts:97](https://github.com/justjake/quickjs-emscripten/blob/main/ts/variants.ts#L97)
___
### newQuickJSWASMModule
▸ **newQuickJSWASMModule**(`variant?`): `Promise`<[`QuickJSWASMModule`](classes/QuickJSWASMModule.md)\>
Create a new, completely isolated WebAssembly module containing the QuickJS library.
See the documentation on [QuickJSWASMModule](classes/QuickJSWASMModule.md).
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
| Name | Type | Default value |
| :------ | :------ | :------ |
| `variant` | [`SyncBuildVariant`](interfaces/SyncBuildVariant.md) | `RELEASE_SYNC` |
#### Returns
`Promise`<[`QuickJSWASMModule`](classes/QuickJSWASMModule.md)\>
#### Defined in
[ts/variants.ts:67](https://github.com/justjake/quickjs-emscripten/blob/main/ts/variants.ts#L67)
___
### shouldInterruptAfterDeadline
▸ **shouldInterruptAfterDeadline**(`deadline`): [`InterruptHandler`](modules.md#interrupthandler)
Returns an interrupt handler that interrupts Javascript execution after a deadline time.
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `deadline` | `number` \| `Date` | Interrupt execution if it's still running after this time. Number values are compared against `Date.now()` |
#### Returns
[`InterruptHandler`](modules.md#interrupthandler)
#### Defined in
[ts/index.ts:150](https://github.com/justjake/quickjs-emscripten/blob/main/ts/index.ts#L150)
|