A class representing the absence of a value in the WeakOption pattern. This class implements the "None" case of the Option pattern, providing safe handling when no value exists.
const none = new WeakNone<MyObject>();const obj = new MyObject();const value = none.unwrapOrDefault(obj, "default"); // Always returns "default" Copy
const none = new WeakNone<MyObject>();const obj = new MyObject();const value = none.unwrapOrDefault(obj, "default"); // Always returns "default"
The base object type used as a key
Checks if a value exists (always returns false).
Always false
Returns this instance (for chaining operations).
This WeakNone instance
Throws an error since no value exists.
Always throws since no value exists
Returns the default value since no value exists.
The type of the default value
The default value to return
The default value
Executes the function since no value exists.
Function to execute
The result of the function
Returns undefined since no value exists.
Always undefined
A class representing the absence of a value in the WeakOption pattern. This class implements the "None" case of the Option pattern, providing safe handling when no value exists.
Example