Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(isFiniteNumber): add isFiniteNumber #929

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

HoberMin
Copy link

@HoberMin HoberMin commented Jan 7, 2025

Add isFiniteNumber utility function

Summary

Added a new utility function isFiniteNumber that checks if a given value is a finite number. This function also acts as a TypeScript type predicate, helping with type narrowing in TypeScript code.

Implementation Details

  • Function takes any value (unknown type) as input
  • Returns boolean indicating if the value is a finite number
  • Implements type predicate functionality (value is number)
  • Uses native typeof and isFinite checks

Usage Examples

import { isFiniteNumber } from '@utils/number';

// Regular numbers
isFiniteNumber(42)        // true
isFiniteNumber(-123.45)   // true

// Special number values
isFiniteNumber(Infinity)  // false
isFiniteNumber(-Infinity) // false
isFiniteNumber(NaN)      // false

// Non-number values
isFiniteNumber('123')     // false
isFiniteNumber(null)      // false
isFiniteNumber(undefined) // false

@HoberMin HoberMin requested a review from raon0211 as a code owner January 7, 2025 07:15
Copy link

vercel bot commented Jan 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
es-toolkit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 7:54am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant