@bytebury/sauce - v1.4.0
    Preparing search index...

    Class OptionConstructor<T>

    Represents a thing that may or may not have a value.

    Very useful when dealing with things that might be null or undefined.

    const value = wrap(mightBeNull).unwrapOr(100);
    

    Type Parameters

    • T

    Implements

    Index

    Constructors

    Methods

    • Determines if the underlying value is None.

      Returns boolean

    • Determines if the underlying value is None, or the predicate using the Some value is true.

      Parameters

      • fn: (x: T) => boolean

      Returns boolean

    • Determines if the underlying value is something.

      Returns boolean

    • Determines if the underlying value is something, and the predicate using that same value is also true.

      Parameters

      • fn: (x: T) => boolean

      Returns boolean

    • Unwrap the underlying value and returns it. If the value is None then this function will throw an error.

      Returns T

      an error when underlying value is None.

    • Unwraps the underlying value, or returns the given value if the underlying value is None.

      Parameters

      • value: unknown

      Returns unknown