Options
All
  • Public
  • Public/Protected
  • All
Menu

Module function/optional

Index

References

Functions

References

Renames and re-exports optional

Functions

  • optional<T, F>(fn: (x: T) => F, x: T): true | F
  • optional<T, F>(fn: (x: T) => F): (x: T) => true | F
  • Wraps a one-parameter function, new function returns true if passed parameter is undefined, otherwise returns result of calling fn

    example
     const optIsString = optional(isString);
    optIsString() //=> true
    optIsString({}) //=> false
    optIsString('str') //=> true

    Type parameters

    • T

    • F

    Parameters

    • fn: (x: T) => F

      function to wrap

        • (x: T): F
        • Parameters

          • x: T

          Returns F

    • x: T

    Returns true | F

  • Wraps a one-parameter function, new function returns true if passed parameter is undefined, otherwise returns result of calling fn

    example
     const optIsString = optional(isString);
    optIsString() //=> true
    optIsString({}) //=> false
    optIsString('str') //=> true

    Type parameters

    • T

    • F

    Parameters

    • fn: (x: T) => F

      function to wrap

        • (x: T): F
        • Parameters

          • x: T

          Returns F

    Returns (x: T) => true | F

      • (x: T): true | F
      • Parameters

        • x: T

        Returns true | F

Generated using TypeDoc