Takes a number and returns a fallback value if that number is NaN.
This is mostly a development utility for prettier code rather than for effective performance.
PKG_VERSION
export function toValidNumber<T_Fallback extends any>( numberLike: any, fallback: null | T_Fallback = null,): number | null | T_Fallback { const numberOrNan = Number( numberLike ); return Number.isNaN( numberOrNan ) ? fallback : numberOrNan;} Copy
export function toValidNumber<T_Fallback extends any>( numberLike: any, fallback: null | T_Fallback = null,): number | null | T_Fallback { const numberOrNan = Number( numberLike ); return Number.isNaN( numberOrNan ) ? fallback : numberOrNan;}
Optional
Takes a number and returns a fallback value if that number is NaN.
This is mostly a development utility for prettier code rather than for effective performance.
Since
PKG_VERSION
Source