CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lodash-isinteger

The lodash method isInteger exported as a module for checking if a value is an integer

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

lodash.isinteger

lodash.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.

Package Information

  • Package Name: lodash.isinteger
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash.isinteger

Core Imports

var isInteger = require('lodash.isinteger');

For ES6 modules (with transpiler):

import isInteger from 'lodash.isinteger';

Basic Usage

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));   // => false

Capabilities

Integer Validation

Checks 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 type

Return Value:

  • boolean: Returns true if value is an integer, false otherwise

Behavior:

  • Returns true for whole numbers (positive, negative, or zero)
  • Returns false for decimal numbers, strings, objects, null, undefined
  • Returns false for special number values like Infinity, -Infinity, and NaN
  • Handles edge cases like Number.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)

docs

index.md

tile.json