@metreeca/core - v0.10.0
    Preparing search index...

    Function isDefined

    • Checks if a value is Defined.

      Only undefined is rejected: null and falsy values such as 0, "", and false are all defined. On success the value narrows to its declared type without undefined, so the guard doubles as a filtering predicate, as in values.filter(value => isDefined(value)).

      A type guard may be supplied to constrain the value beyond mere presence: absence is rejected on its own, whether or not the guard would admit it, so the value narrows to the guarded type stripped of undefined, and a guard built over an Optional type is confined to its present values.

      Type Parameters

      • T

        The type validated by the type guard, or unknown where no guard is given

      Parameters

      • value: unknown

        The value to check

      • Optionalis: Guard<T>

        An optional type guard to validate the value against once presence is established

      Returns value is Defined<T>

      True if the value is not undefined and satisfies the type guard, if one is given; false otherwise