CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lodash-isfinite

The lodash method _.isFinite exported as a module for checking if a value is a finite primitive number.

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

The lodash method _.isFinite exported as a standalone module for checking if a value is a finite primitive number. This module provides a more strict implementation than JavaScript's native isFinite function by ensuring the value is actually a number type before checking finiteness.

Package Information

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

Core Imports

var isFinite = require('lodash.isfinite');

For modern JavaScript environments:

const isFinite = require('lodash.isfinite');

Note: This is a CommonJS module and does not support ESM (import/export) syntax. For ESM environments, use dynamic imports:

const isFinite = (await import('lodash.isfinite')).default;

Basic Usage

var isFinite = require('lodash.isfinite');

// Finite numbers
isFinite(3);
// => true

isFinite(Number.MIN_VALUE);
// => true

isFinite(-1000.5);
// => true

// Non-finite numbers
isFinite(Infinity);
// => false

isFinite(-Infinity);
// => false

isFinite(NaN);
// => false

// Non-numbers (key difference from native isFinite)
isFinite('3');
// => false (native isFinite would return true)

isFinite(null);
// => false (native isFinite would return true)

isFinite(undefined);
// => false

Capabilities

isFinite Function

Checks if a value is a finite primitive number. Unlike JavaScript's native isFinite function, this method does not coerce values to numbers and returns false for non-number types.

/**
 * Checks if `value` is a finite primitive number.
 * 
 * Note: This method is based on Number.isFinite.
 * 
 * @param {*} value - The value to check.
 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
 * @since 0.1.0
 * @category Lang
 */
function isFinite(value);

Key Behavior:

  • Returns true only for values that are both of type number AND finite
  • Returns false for Infinity, -Infinity, and NaN
  • Returns false for all non-number types including string numbers like '3'
  • More strict than native isFinite which coerces values to numbers first

Common Use Cases:

  • Validating numeric input before mathematical operations
  • Checking if a calculated result is a valid finite number
  • Input sanitization where only actual numbers should be accepted
  • Data validation in forms or APIs where strict number validation is required

docs

index.md

tile.json