Class WeakSome<B, T>

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"

Type Parameters

  • B extends object

    The base object type used as a key in the WeakMap

  • T

    The type of the value being stored

Implements

Constructors

  • Creates a new WeakSome instance with a guaranteed value.

    Type Parameters

    • B extends object
    • T

    Parameters

    • base: B

      The base object to use as a key

    • value: T

      The value to store (guaranteed to exist)

    Returns WeakSome<B, T>

Methods

  • Unwraps the value, ignoring the alternative value since this value always exists.

    Parameters

    • base: B

      The base object used as a key

    • altValue: T

      The alternative value (ignored)

    Returns T

    The stored value

  • Unwraps the value, ignoring the function since this value always exists.

    Parameters

    • base: B

      The base object used as a key

    • f: ((value: T) => T)

      Function to execute (ignored)

        • (value): T
        • Parameters

          • value: T

          Returns T

    Returns T

    The stored value