A WeakMap-based implementation representing a value that definitely exists. This class is used when you know a value exists and want to provide type-safe access to it through the WeakOption interface.
const obj = new MyObject();const some = new WeakSome(obj, "definite value");const value = some.unwrapForce(obj); // Always returns "definite value" Copy
const obj = new MyObject();const some = new WeakSome(obj, "definite value");const value = some.unwrapForce(obj); // Always returns "definite value"
The base object type used as a key in the WeakMap
The type of the value being stored
Creates a new WeakSome instance with a guaranteed value.
The base object to use as a key
The value to store (guaranteed to exist)
Gets the value directly (convenience method).
The base object used as a key
The stored value
Checks if a value exists (always returns true).
The base object used as a key (unused)
Always true
Forcefully unwraps the value (always succeeds since the value exists).
Unwraps the value, ignoring the alternative value since this value always exists.
The alternative value (ignored)
Unwraps the value, ignoring the function since this value always exists.
Function to execute (ignored)
Unwraps the value or returns undefined (always returns the value).
A WeakMap-based implementation representing a value that definitely exists. This class is used when you know a value exists and want to provide type-safe access to it through the WeakOption interface.
Example