Class: Scope
February 16, 2026 ยท View on GitHub
quickjs-emscripten / quickjs-emscripten-core / Scope
Class: Scope
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:265
Scope helps reduce the burden of manually tracking and disposing of Lifetimes. See withScope. and withScopeAsync.
Contents
Extends
Implements
Constructors
Constructor
new Scope():
Scope
Returns
Scope
Inherited from
Accessors
alive
Get Signature
get alive():
boolean
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:333
Returns
boolean
true if the object is alive
Implementation of
Overrides
Methods
[dispose]()
[dispose]():
void
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:47
Just calls the standard .dispose() method of this class.
Returns
void
Implementation of
Inherited from
dispose()
dispose():
void
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:337
Dispose of the underlying resources used by this object.
Returns
void
Implementation of
Overrides
manage()
manage<
T>(lifetime):T
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:328
Track lifetime so that it is disposed when this scope is disposed.
Type Parameters
T
T extends Disposable
Parameters
lifetime
T
Returns
T
withScope()
staticwithScope<R>(block):R
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:273
Run block with a new Scope instance that will be disposed after the block returns.
Inside block, call scope.manage on each lifetime you create to have the lifetime
automatically disposed after the block returns.
Type Parameters
R
R
Parameters
block
(scope) => R
Returns
R
Warning
Do not use with async functions. Instead, use withScopeAsync.
withScopeAsync()
staticwithScopeAsync<R>(block):Promise<R>
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:310
Run block with a new Scope instance that will be disposed after the
block's returned promise settles. Inside block, call scope.manage on each
lifetime you create to have the lifetime automatically disposed after the
block returns.
Type Parameters
R
R
Parameters
block
(scope) => Promise<R>
Returns
Promise<R>
withScopeMaybeAsync()
staticwithScopeMaybeAsync<Return,This,Yielded>(_this,block):Return|Promise<Return>
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:286
Type Parameters
Return
Return
This
This
Yielded
Yielded
Parameters
_this
This
block
MaybeAsyncBlock<Return, This, Yielded, [Scope]>
Returns
Return | Promise<Return>