UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

32 lines (30 loc) 656 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/number/isInt.ts /** * `isInt(value)` * * Returns `true` if `value` is an integer, otherwise `false`. This function acts as a type guard. * * ```ts * isInt(42); // true * isInt(-7); // true * isInt(0); // true * isInt(3.14); // false * isInt(NaN); // false * isInt(Infinity); // false * ``` * * ```ts * pipe(42, isInt()); // true * pipe(-7, isInt()); // true * pipe(0, isInt()); // true * pipe(3.14, isInt()); // false * pipe(NaN, isInt()); // false * pipe(Infinity, isInt()); // false * ``` */ const isInt = dfdlT((value) => { return Number.isInteger(value); }, 1); //#endregion export { isInt };