Skip to content

Conversation

lionel-rowe
Copy link
Contributor

@lionel-rowe lionel-rowe commented Sep 12, 2025

Closes #6803

  • clamp: Clamp a number within a range. Based on Math.clamp proposal, with a notable difference being that current proposal specifies TypeErrors for NaN inputs, whereas my version returns NaNs, because throwing TypeErrors seems rather unexpected given the corresponding behavior of Math.min and Math.max.
  • modulo: Floor modulo operation, in contrast with JS's % remainder operator. Based on Python's % (floor modulo) operator and modulus math proposal.
  • round-to: Round a number to a specified number of decimal places using various rounding strategies. Basically Number#toFixed but returning a number instead of a string.

Probably worth kicking the wheels for things like floating-point rounding issues, in cases where those are avoidable or optimizable.

@lionel-rowe lionel-rowe requested a review from kt3k as a code owner September 12, 2025 13:50
@lionel-rowe lionel-rowe force-pushed the math-package branch 4 times, most recently from 5b9bc11 to 98eb5e1 Compare September 12, 2025 14:00
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (91d1d55) to head (3166629).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6823      +/-   ##
==========================================
- Coverage   94.16%   94.16%   -0.01%     
==========================================
  Files         573      577       +4     
  Lines       42400    42454      +54     
  Branches     6732     6746      +14     
==========================================
+ Hits        39928    39978      +50     
- Misses       2422     2425       +3     
- Partials       50       51       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@lionel-rowe lionel-rowe force-pushed the math-package branch 2 times, most recently from dac2f0f to 132a0be Compare September 13, 2025 08:02
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.

Common math utilities

3 participants