UNPKG

ts-extras

Version:

Essential utilities for TypeScript projects

26 lines (19 loc) 405 B
/** Check whether a value is infinite. @example ``` import {isInfinite} from 'ts-extras'; isInfinite(Number.POSITIVE_INFINITY); //=> true isInfinite(Number.NEGATIVE_INFINITY); //=> true isInfinite(42); //=> false isInfinite(Number.NaN); //=> false ``` @category Type guard */ export function isInfinite(value) { return typeof value === 'number' && (value === Infinity || value === -Infinity); }