ts-data-forge
    Preparing search index...

    Function mapNaN2Undefined

    • Converts NaN values to undefined while preserving all other numbers.

      This function is useful for handling potentially invalid numeric operations in a type-safe way, converting NaN results to undefined for easier handling with optional chaining or nullish coalescing.

      Type Parameters

      • N extends number

        The numeric type (literal or number)

      Parameters

      • num: N

        The number to check

      Returns RelaxedExclude<N, NaNType> | undefined

      The original number if not NaN, otherwise undefined