isguard-ts
    Preparing search index...

    Function isMaybe

    • Creates a MaybeTypeGuard that checks that the value is either null or of type T.

      Can be shortened with TypeGuard.maybe.

      Type Parameters

      • T

        The type to make nullable

      Parameters

      • guard: TypeGuard<T>

        The type guard for the base type T

      Returns MaybeTypeGuard<T>

      A type guard for T | null

      const isMaybeNumber = isMaybe(isNumber); // or isNumber.maybe()

      isMaybeNumber(5); // true
      isMaybeNumber(null); // true
      isMaybeNumber("hello"); // false