t-tasks
    Preparing search index...

    Interface Just<R>

    Just a value

    Maybe data type specialization representing an existing value

    interface Just<R> {
        generator: MaybeGeneratorFunction<[], R, Just<R>, R>;
        just: R;
        chain<R2>(this: Just<R>, op: (value: R) => Just<R2>): Just<R2>;
        chain<R2>(this: Just<R>, op: (value: R) => Nothing<R2>): Nothing<never>;
        chain<R2>(this: Just<R>, op: (value: R) => Maybe<R2>): Maybe<R2>;
        chain<R2>(this: Maybe<R>, op: (value: R) => Just<R2>): Maybe<R2>;
        chain<R2>(this: Maybe<R>, op: (value: R) => Nothing<R2>): Nothing<never>;
        chain<R2>(this: Maybe<R>, op: (value: R) => Maybe<R2>): Maybe<R2>;
        isJust(): this is Just<R>;
        isNothing(): this is Nothing<R>;
        map<R2>(this: Just<R>, op: (value: R) => R2): Just<R2>;
        map<R2>(this: Maybe<R>, op: (value: R) => R2): Maybe<R2>;
        match<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => R2; nothing: () => R3 },
        ): R2;
        match<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => R2; nothing: () => R3 },
        ): R2 | R3;
        matchChain<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => Just<R2>; nothing: () => Just<R3> },
        ): Just<R2>;
        matchChain<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => Just<R2>; nothing: () => Nothing<R3> },
        ): Just<R2>;
        matchChain<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => Nothing<R2>; nothing: () => Just<R3> },
        ): Nothing<never>;
        matchChain<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => Nothing<R2>; nothing: () => Nothing<R3> },
        ): Nothing<never>;
        matchChain<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => Just<R2>; nothing: () => Maybe<R3> },
        ): Just<R2>;
        matchChain<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => Nothing<R2>; nothing: () => Maybe<R3> },
        ): Nothing<never>;
        matchChain<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => Maybe<R2>; nothing: () => Just<R3> },
        ): Maybe<R2>;
        matchChain<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => Maybe<R2>; nothing: () => Nothing<R3> },
        ): Maybe<R2>;
        matchChain<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => Maybe<R2>; nothing: () => Maybe<R3> },
        ): Maybe<R2>;
        matchChain<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => Just<R2>; nothing: () => Just<R3> },
        ): Just<R2 | R3>;
        matchChain<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => Just<R2>; nothing: () => Nothing<R3> },
        ): Maybe<R2>;
        matchChain<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => Nothing<R2>; nothing: () => Just<R3> },
        ): Maybe<R3>;
        matchChain<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => Nothing<R2>; nothing: () => Nothing<R3> },
        ): Nothing<never>;
        matchChain<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => Just<R2>; nothing: () => Maybe<R3> },
        ): Maybe<R2 | R3>;
        matchChain<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => Nothing<R2>; nothing: () => Maybe<R3> },
        ): Maybe<R3>;
        matchChain<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => Maybe<R2>; nothing: () => Just<R3> },
        ): Maybe<R2 | R3>;
        matchChain<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => Maybe<R2>; nothing: () => Nothing<R3> },
        ): Maybe<R2>;
        matchChain<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => Maybe<R2>; nothing: () => Maybe<R3> },
        ): Maybe<R2 | R3>;
        matchMap<R2, R3 = R2>(
            this: Just<R>,
            op: { just: (value: R) => R2; nothing: () => R3 },
        ): Just<R2>;
        matchMap<R2, R3 = R2>(
            this: Maybe<R>,
            op: { just: (value: R) => R2; nothing: () => R3 },
        ): Just<R2 | R3>;
        matchTap(op: { just: (value: R) => void; nothing: () => void }): this;
        orChain<R2>(this: Just<R>, op: () => Just<R2>): Just<R>;
        orChain<R2>(this: Just<R>, op: () => Nothing<R2>): Just<R>;
        orChain<R2>(this: Just<R>, op: () => Maybe<R2>): Just<R>;
        orChain<R2>(this: Maybe<R>, op: () => Just<R2>): Just<R | R2>;
        orChain<R2>(this: Maybe<R>, op: () => Nothing<R2>): Maybe<R>;
        orChain<R2>(this: Maybe<R>, op: () => Maybe<R2>): Maybe<R | R2>;
        orMap<R2>(this: Just<R>, op: () => R2): Just<R>;
        orMap<R2>(this: Maybe<R>, op: () => R2): Just<R | R2>;
        orTap(op: () => void): this;
        tap(op: (value: R) => void): this;
    }

    Type Parameters

    • R

      underlying value

    Index

    Properties

    generator: MaybeGeneratorFunction<[], R, Just<R>, R>

    Wrap Maybe to singleton generator

    Useful in order to avoid ambiguous yield types

    generator of Maybe wrapping this

    just: R

    Methods

    • Maybe type guard for 'just'

      Returns this is Just<R>

      'true' in case wrapped value exists (and resolves this type to be 'just')

      if (maybe.isJust()) {
      console.log(maybe.just);
      }
    • Maybe type guard for 'nothing'

      Returns this is Nothing<R>

      'true' in case wrapped value is 'nothing' (and resolves this type to be 'nothing')

      if (maybe.isNothing()) {
      console.log('nothing');
      }
    • Maybe transformer function

      Applied to 'just value' returns 'just op(value)' Applied to 'nothing' returns self without invoking transformer

      Type Parameters

      • R2

        transformer function's return type

      Parameters

      • this: Just<R>
      • op: (value: R) => R2

        transformer to be invoked with underlying value

      Returns Just<R2>

      'just op(value)' or 'nothing'

    • Type Parameters

      • R2

      Parameters

      Returns Maybe<R2>

    • Maybe pattern matching extractor function

      Applied to 'just value' returns op.just(value) Applied to 'nothing' returns op.nothing()

      Type Parameters

      • R2

        just extractor function's return type

      • R3 = R2

        nothing extractor function's return type

      Parameters

      • this: Just<R>
      • op: { just: (value: R) => R2; nothing: () => R3 }
        • just: (value: R) => R2

          extractor to be invoked with underlying value in case of just

        • nothing: () => R3

          extractor to be invoked in case of nothing

      Returns R2

      op.just(value) or op.nothing()

    • Type Parameters

      Parameters

      • this: Maybe<R>
      • op: { just: (value: R) => R2; nothing: () => R3 }

      Returns R2 | R3

    • Maybe pattern matching transformer function

      Applied to 'just value' returns 'just op.just(value)' Applied to 'nothing' returns 'just op.nothing()'

      Type Parameters

      • R2

        just transformer function's return type

      • R3 = R2

        nothing transformer function's return type

      Parameters

      • this: Just<R>
      • op: { just: (value: R) => R2; nothing: () => R3 }
        • just: (value: R) => R2

          transformer to be invoked with underlying value in case of just

        • nothing: () => R3

          transformer to be invoked in case of nothing

      Returns Just<R2>

      'just op.just(value)' or 'just op.nothing()'

    • Type Parameters

      Parameters

      • this: Maybe<R>
      • op: { just: (value: R) => R2; nothing: () => R3 }

      Returns Just<R2 | R3>

    • Maybe pattern matching peeker function

      Applied to 'just value' returns self invoking op.just(value) in process Applied to 'nothing' returns self invoking op.nothing() in process

      Parameters

      • op: { just: (value: R) => void; nothing: () => void }
        • just: (value: R) => void

          function to be invoked with underlying value in case of just

        • nothing: () => void

          function to be invoked in case of nothing

      Returns this

      self

    • Maybe fallback transformer function

      Applied to 'just value' returns self without invoking transformer Applied to 'nothing' returns 'just op()'

      Type Parameters

      • R2

        transformer function's return type

      Parameters

      • this: Just<R>
      • op: () => R2

        function to be invoked

      Returns Just<R>

      'just value' or 'just op()'

    • Type Parameters

      • R2

      Parameters

      Returns Just<R | R2>

    • Maybe fallback peeker function

      Applied to 'just value' returns self without invoking callback Applied to 'nothing' returns self invoking op() in process

      Parameters

      • op: () => void

        function to be invoked

      Returns this

      self

    • Maybe peeker function

      Applied to 'just value' returns self invoking op(value) in process Applied to 'nothing' returns self without invoking callback

      Parameters

      • op: (value: R) => void

        function to be invoked with underlying value

      Returns this

      self