Type Parameters

  • T

Hierarchy

  • Maybe

Methods

  • Returns the first Just between this and another Maybe or Nothing if both this and the argument are Nothing

    Parameters

    Returns functional.Maybe<T>

  • Structural pattern matching for Maybe in the form of a function

    Type Parameters

    • U

    Parameters

    Returns U

  • Transforms this with a function that returns a nullable value. Equivalent to m.chain(x => Maybe.fromNullable(f(x)))

    Type Parameters

    • U

    Parameters

    • f: ((value) => undefined | null | void | U)
        • (value): undefined | null | void | U
        • Parameters

          • value: T

          Returns undefined | null | void | U

    Returns functional.Maybe<U>

  • Compares the values inside this and the argument, returns true if both are Nothing or if the values are equal

    Parameters

    Returns boolean

  • Returns this if it's Nothing, otherwise it returns the result of applying the function argument to this and wrapping it in a Just

    Type Parameters

    • U

    Parameters

    Returns functional.Maybe<U>

  • Returns the value inside this or undefined if this is Nothing. Use extractNullable if you need a null returned instead

    Returns ExtractMaybe<T, undefined>

  • Returns the value inside this or null if this is Nothing. Use extract if you need an undefined returned instead

    Returns ExtractMaybe<T, null>

  • Parameters

    Returns boolean

  • Type Parameters

    • U

    Parameters

    • pred: ((value) => boolean)
        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns functional.Maybe<U>

  • Parameters

    • pred: ((value) => boolean)
        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns functional.Maybe<T>

  • Type Parameters

    • U

    Parameters

    • f: ((value) => U)
        • (value): U
        • Parameters

          • value: T

          Returns U

    Returns functional.Maybe<U>

  • Type Parameters

    • U

    Parameters

    • reducer: ((accumulator, value) => U)
        • (accumulator, value): U
        • Parameters

          • accumulator: U
          • value: T

          Returns U

    • initialValue: U

    Returns U

  • Takes a predicate function and returns this if the predicate returns true or Nothing if it returns false

    Type Parameters

    • U

    Parameters

    • pred: ((value) => value is U)
        • (value): value is U
        • Parameters

          • value: T

          Returns value is U

    Returns functional.Maybe<U>

  • Takes a predicate function and returns this if the predicate returns true or Nothing if it returns false

    Parameters

    • pred: ((value) => boolean)
        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns functional.Maybe<T>

  • Runs an effect if this is Just, returns this to make chaining other methods possible

    Parameters

    • effect: ((value) => any)
        • (value): any
        • Parameters

          • value: T

          Returns any

    Returns functional.Maybe<T>

  • Runs an effect if this is Nothing, returns this to make chaining other methods possible

    Parameters

    • effect: (() => any)
        • (): any
        • Returns any

    Returns functional.Maybe<T>

  • Returns string

  • Returns true if this is Just, otherwise it returns false

    Returns this is AlwaysJust

  • Returns true if this is Nothing, otherwise it returns false

    Returns this is Nothing

  • Transforms the value inside this with a given function. Returns Nothing if this is Nothing

    Type Parameters

    • U

    Parameters

    • f: ((value) => U)
        • (value): U
        • Parameters

          • value: T

          Returns U

    Returns functional.Maybe<U>

  • Maps over this and returns the resulting value or returns the default value if this is Nothing

    Type Parameters

    • U

    Parameters

    • f: ((value) => U)
        • (value): U
        • Parameters

          • value: T

          Returns U

    • defaultValue: U

    Returns U

  • Returns the default value if this is Nothing, otherwise it return the value inside this

    Parameters

    • defaultValue: T

    Returns T

  • Lazy version of orDefault. Takes a function that returns the default value, that function will be called only if this is Nothing

    Parameters

    • getDefaultValue: (() => T)
        • (): T
        • Returns T

    Returns T

  • Takes a reducer and an initial value and returns the initial value if this is Nothing or the result of applying the function to the initial value and the value inside this

    Type Parameters

    • U

    Parameters

    • reducer: ((accumulator, value) => U)
        • (accumulator, value): U
        • Parameters

          • accumulator: U
          • value: T

          Returns U

    • initialValue: U

    Returns U

  • Constructs a Right from a Just or a Left with a provided left value if this is Nothing

    Type Parameters

    • L

    Parameters

    • left: L

    Returns functional.Either<L, T>

  • Returns T

  • Returns empty list if the Maybe is Nothing or a list where the only element is the value of Just

    Returns T[]

  • Returns string

  • Returns the value inside this or throws an error if this is Nothing

    Returns T

Generated using TypeDoc