Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix make _.isNumber(NaN) return false and update tests#5982

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Rishiyaduwanshi wants to merge1 commit intolodash:main
base:main
Choose a base branch
Loading
fromRishiyaduwanshi:fix-isNumber-returns-false-for-NaN-5981

Conversation

Rishiyaduwanshi
Copy link

📌 Fix:_.isNumber(NaN) now returnsfalse as expected (Fixes#5981)

🐛 The Issue

In Lodash v4.17.21, the_.isNumber function incorrectly returnstrue forNaN. This is problematic in scenarios where consumers of the library want to distinguish valid numbers fromNaN.

Reference:Issue #5981

✅ The Fix

TheisNumber function has been updated to returnfalse when the input isNaN. The logic now ensures that:

  • PrimitiveNaN values are filtered out.
  • BoxedNaN values (e.g.,Object(NaN)) are also handled appropriately.
functionisNumber(value){return(typeofvalue=='number'&&!Number.isNaN(value))||(isObjectLike(value)&&baseGetTag(value)==numberTag);}

🧪 Tests Updated

  • Updated test case:assert.strictEqual(_.isNumber(NaN), false);
  • Verified against full test suite usingpnpm test.
  • All tests passing ✅

@Rishiyaduwanshi
Copy link
Author

Hi! Just following up on this PR. Let me know if any changes are needed. Thanks!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

The issue that _.isNumber(NaN) returns true. VERSION 4.17.21
1 participant
@Rishiyaduwanshi

[8]ページ先頭

©2009-2025 Movatter.jp