Skip to content

fix(compat/isNaN): improve NaN checks for boxed values and non-numbers#1646

Open
D-Sketon wants to merge 3 commits intotoss:mainfrom
D-Sketon:fix/isNaN
Open

fix(compat/isNaN): improve NaN checks for boxed values and non-numbers#1646
D-Sketon wants to merge 3 commits intotoss:mainfrom
D-Sketon:fix/isNaN

Conversation

@D-Sketon
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 15, 2026 15:12
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
es-toolkit Ready Ready Preview, Comment Apr 18, 2026 9:27am

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the compat/predicate/isNaN helper to correctly detect NaN for boxed number values (e.g. new Number(NaN)) while still returning false for non-numeric inputs, aligning behavior more closely with lodash.

Changes:

  • Update isNaN implementation to gate on isNumber and handle boxed numbers via numeric unboxing.
  • Extend isNaN tests to cover boxed number inputs (new Number(0) and new Number(NaN)).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/compat/predicate/isNaN.ts Changes isNaN logic to handle boxed numbers via unboxing after a numeric-type gate.
src/compat/predicate/isNaN.spec.ts Adds test cases for boxed non-NaN and boxed NaN values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/compat/predicate/isNaN.ts
Comment thread src/compat/predicate/isNaN.spec.ts
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.97%. Comparing base (c8fec98) to head (04e2d60).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1646   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files         497      497           
  Lines        4660     4660           
  Branches     1348     1349    +1     
=======================================
  Hits         4659     4659           
  Misses          1        1           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants