UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

31 lines (30 loc) 825 B
import { IsFloat } from "type-fest"; //#region src/number/isFloat.d.ts type Float<T> = T extends unknown ? number extends T ? T : IsFloat<T> extends true ? T : never : never; /** * `isFloat(value)` * * Returns `true` if `value` is a finite floating-point number (not an integer), otherwise `false`. This function acts as a type guard. * * ```ts * isFloat(3.14); // true * isFloat(0.5); // true * isFloat(42); // false * isFloat(NaN); // false * isFloat(Infinity); // false * ``` * * ```ts * pipe(3.14, isFloat()); // true * pipe(0.5, isFloat()); // true * pipe(42, isFloat()); // false * pipe(NaN, isFloat()); // false * pipe(Infinity, isFloat()); // false * ``` */ declare const isFloat: { <T>(): (value: T) => value is Float<T>; <T>(value: T): value is Float<T>; }; //#endregion export { isFloat };