The lodash method isInteger exported as a module for checking if a value is an integer
npx @tessl/cli install tessl/npm-lodash--isinteger@4.0.0lodash.isinteger is a modularized version of lodash's isInteger utility function that checks if a given value is an integer. It performs type checking to ensure the input is a number and validates that it equals its integer conversion, effectively filtering out decimals, strings, and other non-integer data types.
npm install lodash.isintegervar isInteger = require('lodash.isinteger');For ES6 modules (with transpiler):
import isInteger from 'lodash.isinteger';var isInteger = require('lodash.isinteger');
// Check various values
console.log(isInteger(3)); // => true
console.log(isInteger(3.0)); // => true
console.log(isInteger(3.2)); // => false
console.log(isInteger(Number.MIN_VALUE)); // => false
console.log(isInteger(Infinity)); // => false
console.log(isInteger('3')); // => false
console.log(isInteger(null)); // => false
console.log(isInteger(undefined)); // => falseChecks if a value is an integer by validating it's a number type and equals its integer conversion.
/**
* Checks if `value` is an integer.
*
* Note: This method is based on Number.isInteger.
*
* @param {any} value The value to check.
* @returns {boolean} Returns `true` if `value` is an integer, else `false`.
*/
function isInteger(value);Parameter Details:
value (any): The value to check - can be any typeReturn Value:
boolean: Returns true if value is an integer, false otherwiseBehavior:
true for whole numbers (positive, negative, or zero)false for decimal numbers, strings, objects, null, undefinedfalse for special number values like Infinity, -Infinity, and NaNNumber.MIN_VALUE correctly (returns false)Examples:
// Integer values
isInteger(0); // => true
isInteger(-1); // => true
isInteger(42); // => true
isInteger(3.0); // => true (mathematically an integer)
// Non-integer values
isInteger(3.14); // => false (decimal)
isInteger('3'); // => false (string)
isInteger([]); // => false (array)
isInteger({}); // => false (object)
isInteger(null); // => false
isInteger(undefined); // => false
// Special number values
isInteger(Infinity); // => false
isInteger(-Infinity); // => false
isInteger(NaN); // => false
isInteger(Number.MIN_VALUE); // => false (very small decimal)