/**
* @author [Tristan Valcke]{@link https://github.com/Itee}
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
*
* @module sources/cores/numbers/isInfinite
* @desc Export function to validate if a value is a finite or infinite number
* @example
*
* import { isInfinite } from 'itee-validators'
*
* if( isInfinite( value ) ) {
* //...
* } else {
* //...
* }
*
*/
/**
* Check if the given data is an infinite negative number
*
* @param data {*} The data to check against the negative infinite state
* @returns {boolean} true if data is negative infinite, false otherwise
*/
export function isInfiniteNegative( data ) {
return ( data === Number.NEGATIVE_INFINITY )
}
/**
* Check if the given data is an infinite positive number
*
* @param data {*} The data to check against the positive infinite state
* @returns {boolean} true if data is positive infinite, false otherwise
*/
export function isInfinitePositive( data ) {
return ( data === Number.POSITIVE_INFINITY )
}
/**
* Check if the given data is an infinite number
*
* @param data {*} The data to check against the infinite state
* @returns {boolean} true if data is infinite, false otherwise
*/
export function isInfinite( data ) {
return isInfiniteNegative( data ) || isInfinitePositive( data )
}
/**
* Check if the given data is a finite number
*
* @param data {*} The data to check against the finite state
* @returns {boolean} true if data is finite, false otherwise
*/
export function isFinite( data ) {
return Number.isFinite( data )
}