Class: WeakLifetime\
February 16, 2026 ยท View on GitHub
quickjs-emscripten / quickjs-emscripten-core / WeakLifetime
Class: WeakLifetime<T, TCopy, Owner>
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:223
A Lifetime that does not own its value. A WeakLifetime never calls its
disposer function, but can be duped to produce regular lifetimes that
do.
Used for function arguments.
Contents
Extends
Lifetime<T,TCopy,Owner>
Type Parameters
T
T
TCopy
TCopy = never
Owner
Owner = never
Constructors
Constructor
new WeakLifetime<
T,TCopy,Owner>(value,copier?,disposer?,owner?):WeakLifetime<T,TCopy,Owner>
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:224
Parameters
value
T
copier?
(value) => TCopy
disposer?
(value) => void
owner?
Owner
Returns
WeakLifetime<T, TCopy, Owner>
Overrides
Properties
_alive
protected_alive:boolean=true
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:72
Inherited from
_constructorStack
protected_constructorStack:string|undefined
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:73
Inherited from
_owner?
protectedreadonlyoptional_owner:Owner
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:87
Inherited from
_value
protectedreadonly_value:T
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:84
Inherited from
copier()?
protectedreadonlyoptionalcopier: (value) =>TCopy
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:85
Parameters
value
T | TCopy
Returns
TCopy
Inherited from
disposer()?
protectedreadonlyoptionaldisposer: (value) =>void
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:86
Parameters
value
T | TCopy
Returns
void
Inherited from
Accessors
alive
Get Signature
get alive():
boolean
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:92
Returns
boolean
true if the object is alive
Inherited from
dupable
Get Signature
get dupable():
boolean
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:111
Returns
boolean
Inherited from
owner
Get Signature
get owner():
Owner|undefined
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:107
Returns
Owner | undefined
Inherited from
value
Get Signature
get value():
T
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:102
The value this Lifetime protects. You must never retain the value - it may become invalid, leading to memory errors.
Throws
If the lifetime has been disposed already.
Returns
T
Inherited from
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
Inherited from
assertAlive()
protectedassertAlive():void
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:182
Returns
void
Inherited from
consume()
Call Signature
consume<
O>(map):O
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:135
Call map with this lifetime, then dispose the lifetime.
Type Parameters
O
O
Parameters
map
(lifetime) => O
Returns
O
the result of map(this).
Inherited from
Call Signature
consume<
O>(map):O
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:138
Call map with this lifetime, then dispose the lifetime.
Type Parameters
O
O
Parameters
map
(lifetime) => O
Returns
O
the result of map(this).
Inherited from
dispose()
dispose():
void
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:234
Dispose of value and perform cleanup.
Returns
void
Overrides
dup()
dup():
Lifetime<TCopy,TCopy,Owner>
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:118
Create a new handle pointing to the same value.
Returns
Lifetime<TCopy, TCopy, Owner>
Inherited from
map()
Call Signature
map<
O>(map):O
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:151
Call map with this lifetime, returning the result.
Does not dispose the lifetime.
Type Parameters
O
O
Parameters
map
(lifetime) => O
Returns
O
the result of map(this).
Inherited from
Call Signature
map<
O>(map):O
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:152
Call map with this lifetime, returning the result.
Does not dispose the lifetime.
Type Parameters
O
O
Parameters
map
(lifetime) => O
Returns
O
the result of map(this).
Inherited from
tap()
Call Signature
tap(
fn):this
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:164
Call fn with this lifetime, then return this. Does not dispose the
lifetime. Useful for imperative operations within an expression, like when
you're building up objects, or to add logging in the middle of a call chain.
Parameters
fn
(lifetime) => void
Returns
this
this
Inherited from
Call Signature
tap(
fn):QuickJSHandle
Defined in: packages/quickjs-emscripten-core/src/lifetime.ts:165
Call fn with this lifetime, then return this. Does not dispose the
lifetime. Useful for imperative operations within an expression, like when
you're building up objects, or to add logging in the middle of a call chain.
Parameters
fn
(lifetime) => void
Returns
this