isFinite
lang
Checks if value is a finite primitive number.
Installation
Import
import { isFinite } from '@tulx/utils';Source Code
Implementation
/**
* Checks if value is a finite primitive number.
*
* @param value - The value to check.
* @returns Returns true if value is a finite number, else false.
*
* @example
* ```ts
* isFinite(3); // true
* isFinite(Number.MIN_VALUE); // true
* isFinite(Infinity); // false
* isFinite('3'); // false
* ```
*/
export function isFinite(value: unknown): value is number {
return typeof value === 'number' && Number.isFinite(value);
}
Example
import { isFinite } from '@tulx/utils';
isFinite(3); // true
isFinite(Number.MIN_VALUE); // true
isFinite(Infinity); // false
isFinite('3'); // falseRelated Functions
castArray
Casts value as an array if it's not one.
clone
Creates a shallow clone of value.
cloneDeep
This method is like clone except that it recursively clones value.
cloneDeepWith
This method is like cloneDeep except that it accepts customizer which is invoked to produce the cloned value.
cloneWith
This method is like clone except that it accepts customizer which is invoked to produce the cloned value.
conformsTo
Checks if object conforms to source by invoking the predicate properties of source with the corresponding property values of object.