Function ifIsNullish

  • Applies nullishTransform if the argument is nullish, i.e., null or undefined, and otherTransform if it is not.

    Example

    import * as G from "flurp/guard";
    import * as L from "flurp/logic";

    const nullishToEmpty = G.ifIsNullish([], L.identity);
    nullishToEmpty(null); // []
    nullishToEmpty(undefined); // []
    nullishToEmpty([3, 4, 5]); // [3, 4, 5]

    Type Parameters

    • T

    • U

    Parameters

    • nullishValue: U
    • otherTransform: ((x: T) => U)
        • (x: T): U
        • Parameters

          • x: T

          Returns U

    Returns ((x: undefined | null | T) => U)

      • (x: undefined | null | T): U
      • Parameters

        • x: undefined | null | T

        Returns U