FuncType - v0.16.0
    Preparing search index...

    Interface Extractable<T>

    Extractable type class for data structures that can extract their values with various fallback strategies.

    This interface is implemented by Option, Either, and other types that wrap values and need both safe and fallible extraction methods.

    Extends Unsafe to provide exception-throwing operations alongside safe alternatives.

    interface Extractable<T extends Type> {
        getOrElse(defaultValue: T): T;
        getOrThrow(error?: Error): T;
        orElse(alternative: Extractable<T>): Extractable<T>;
        orNull(): T | null;
        orUndefined(): T | undefined;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Methods

    • Returns the contained value or a default value

      Parameters

      • defaultValue: T

        The value to return if extraction fails

      Returns T

      The contained value or defaultValue

    • Extract the value or throw an error

      Parameters

      • Optionalerror: Error

        Optional custom error to throw. If not provided, uses type-appropriate default error

      Returns T

      The contained value

      The specified error, container's error, or a sensible default

    • Returns this container if it has a value, otherwise returns the alternative

      Parameters

      Returns Extractable<T>

      This container or the alternative

    • Returns the contained value or null

      Returns T | null

      The contained value or null

    • Returns the contained value or undefined

      Returns T | undefined

      The contained value or undefined