@telostat/prelude - v0.7.0
    Preparing search index...

    Interface Maybe<T>

    interface Maybe<T> {
        alt(other: Maybe<T>): Maybe<T>;
        altLazy(other: () => Maybe<T>): Maybe<T>;
        ap<U>(maybeF: Maybe<(value: T) => U>): Maybe<U>;
        caseOf<U>(patterns: MaybePatterns<T, U>): U;
        chain<U>(f: (value: T) => Maybe<U>): Maybe<U>;
        chainNullable<U>(f: (value: T) => void | U | null | undefined): Maybe<U>;
        equals(other: Maybe<T>): boolean;
        extend<U>(f: (value: Maybe<T>) => U): Maybe<U>;
        extract(): ExtractMaybe<T, undefined>;
        extractNullable(): ExtractMaybe<T, null>;
        "fantasy-land/alt"(other: Maybe<T>): Maybe<T>;
        "fantasy-land/ap"<U>(maybeF: Maybe<(value: T) => U>): Maybe<U>;
        "fantasy-land/chain"<U>(f: (value: T) => Maybe<U>): Maybe<U>;
        "fantasy-land/equals"(other: Maybe<T>): boolean;
        "fantasy-land/extend"<U>(f: (value: Maybe<T>) => U): Maybe<U>;
        "fantasy-land/filter"<U>(pred: (value: T) => boolean): Maybe<U>;
        "fantasy-land/filter"(pred: (value: T) => boolean): Maybe<T>;
        "fantasy-land/map"<U>(f: (value: T) => U): Maybe<U>;
        "fantasy-land/reduce"<U>(
            reducer: (accumulator: U, value: T) => U,
            initialValue: U,
        ): U;
        filter<U>(pred: (value: T) => value is U): Maybe<U>;
        filter(pred: (value: T) => boolean): Maybe<T>;
        ifJust(effect: (value: T) => any): this;
        ifNothing(effect: () => any): this;
        inspect(): string;
        isJust(): this is AlwaysJust;
        isNothing(): this is Nothing;
        join<U>(this: Maybe<Maybe<U>>): Maybe<U>;
        map<U>(f: (value: T) => U): Maybe<U>;
        mapOrDefault<U>(f: (value: T) => U, defaultValue: U): U;
        orDefault(defaultValue: T): T;
        orDefaultLazy(getDefaultValue: () => T): T;
        reduce<U>(reducer: (accumulator: U, value: T) => U, initialValue: U): U;
        toEither<L>(left: L): Either<L, T>;
        toJSON(): T;
        toList(): T[];
        toString(): string;
        unsafeCoerce(): T;
    }

    Type Parameters

    • T
    Index

    Methods

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

      Parameters

      Returns Maybe<T>

    • Lazy version of alt

      Parameters

      Returns Maybe<T>

    • Maps this with a Maybe function

      Type Parameters

      • U

      Parameters

      Returns Maybe<U>

    • 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 Maybe. Useful for chaining many computations that may result in a missing value

      Type Parameters

      • U

      Parameters

      Returns Maybe<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: T) => void | U | null | undefined

      Returns 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 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 Maybe<T>

    • Type Parameters

      • U

      Parameters

      Returns Maybe<U>

    • Type Parameters

      • U

      Parameters

      Returns Maybe<U>

    • Parameters

      Returns boolean

    • Type Parameters

      • U

      Parameters

      Returns Maybe<U>

    • Type Parameters

      • U

      Parameters

      • pred: (value: T) => boolean

      Returns Maybe<U>

    • Parameters

      • pred: (value: T) => boolean

      Returns Maybe<T>

    • Type Parameters

      • U

      Parameters

      • f: (value: T) => U

      Returns Maybe<U>

    • Type Parameters

      • U

      Parameters

      • reducer: (accumulator: U, value: T) => 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: T) => value is U

      Returns Maybe<U>

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

      Parameters

      • pred: (value: T) => boolean

      Returns Maybe<T>

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

      Parameters

      • effect: (value: T) => any

      Returns this

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

      Parameters

      • effect: () => any

      Returns this

    • 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

    • Flattens nested Maybes. m.join() is equivalent to m.chain(x => x)

      Type Parameters

      • U

      Parameters

      Returns Maybe<U>

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

      Type Parameters

      • U

      Parameters

      • f: (value: T) => U

      Returns 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: T) => 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

      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: U, value: T) => 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 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