Class WeakNone<B>

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"

Type Parameters

  • B extends object

    The base object type used as a key

Implements

Constructors

Methods

  • Returns the default value since no value exists.

    Type Parameters

    • T

      The type of the default value

    Parameters

    • base: B

      The base object used as a key (unused)

    • value: T

      The default value to return

    Returns T

    The default value

  • Executes the function since no value exists.

    Parameters

    • base: B

      The base object used as a key (unused)

    • f: ((...vals: any) => never)

      Function to execute

        • (...vals): never
        • Parameters

          • Rest...vals: any

          Returns never

    Returns never

    The result of the function