rhodonite
    Preparing search index...

    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

    Index
    • Creates a new WeakSome instance with a guaranteed 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

      Parameters

      • base: B

        The base object to use as a key

      • value: T

        The value to store (guaranteed to exist)

      Returns WeakSome<B, T>

    • Gets the value directly (convenience method).

      Parameters

      • base: B

        The base object used as a key

      Returns T

      The stored value

    • Checks if a value exists (always returns true).

      Parameters

      • _base: B

      Returns true

      Always true

    • Forcefully unwraps the value (always succeeds since the value exists).

      Parameters

      • base: B

        The base object used as a key

      Returns T

      The stored value

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

      Parameters

      • base: B

        The base object used as a key

      • _altValue: T

      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

      Returns T

      The stored value

    • Unwraps the value or returns undefined (always returns the value).

      Parameters

      • base: B

        The base object used as a key

      Returns T | undefined

      The stored value