Options
All
  • Public
  • Public/Protected
  • All
Menu

Module function/ifElse

Index

References

Functions

References

Renames and re-exports ifElse

Functions

  • ifElse<T, F>(condition: Func<boolean>, onTrue: Func<T>, onFalse: Func<F>): Func<T | F>
  • ifElse<T>(condition: Func<boolean>, onTrue: Func<T>): <F>(onFalse: Func<F>) => Func<T | F>
  • ifElse(condition: Func<boolean>): { <T, F>(onTrue: Func<T>, onFalse: Func<F>): Func<T | F>; <T>(onTrue: Func<T>): <F>(onFalse: Func<F>) => Func<T | F> }
  • Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

    example
     const prop = ifElse(
    x => x.a,
    x => x.b,
    x => x.c
    );
    prop({ a: false, c: 2 }); //=> 2
    prop({ a: true, b: 1, c: 2 }); //=> 1

    Type parameters

    • T

    • F

    Parameters

    • condition: Func<boolean>

      A predicate function

    • onTrue: Func<T>

      A function to invoke when the condition evaluates to a truthy value.

    • onFalse: Func<F>

      A function to invoke when the condition evaluates to a falsy value.

    Returns Func<T | F>

    A new unary function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

  • Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

    example
     const prop = ifElse(
    x => x.a,
    x => x.b,
    x => x.c
    );
    prop({ a: false, c: 2 }); //=> 2
    prop({ a: true, b: 1, c: 2 }); //=> 1

    Type parameters

    • T

    Parameters

    • condition: Func<boolean>

      A predicate function

    • onTrue: Func<T>

      A function to invoke when the condition evaluates to a truthy value.

    Returns <F>(onFalse: Func<F>) => Func<T | F>

    A new unary function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

      • Type parameters

        • F

        Parameters

        Returns Func<T | F>

  • Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

    example
     const prop = ifElse(
    x => x.a,
    x => x.b,
    x => x.c
    );
    prop({ a: false, c: 2 }); //=> 2
    prop({ a: true, b: 1, c: 2 }); //=> 1

    Parameters

    • condition: Func<boolean>

      A predicate function

    Returns { <T, F>(onTrue: Func<T>, onFalse: Func<F>): Func<T | F>; <T>(onTrue: Func<T>): <F>(onFalse: Func<F>) => Func<T | F> }

    A new unary function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

      • Type parameters

        • T

        • F

        Parameters

        Returns Func<T | F>

      • Type parameters

        • T

        Parameters

        Returns <F>(onFalse: Func<F>) => Func<T | F>

          • Type parameters

            • F

            Parameters

            Returns Func<T | F>

Generated using TypeDoc