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: add clamp function #106

Merged
merged 1 commit into from
Jul 13, 2024
Merged

feat: add clamp function #106

merged 1 commit into from
Jul 13, 2024

Conversation

aleclarson
Copy link
Member

@aleclarson aleclarson commented Jul 12, 2024

Tip

The owner of this PR can publish a preview release by commenting /publish in this PR. Afterwards, anyone can try it out by running pnpm add radashi@pr<PR_NUMBER>.

Summary

The clamp function is like a combination of Math.min and Math.max. Both the min and max can be nullish, in which case they are ignored.

Resolves lodash/lodash#3139 – When the min is > max, an error is thrown by Radashi.

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed
  • Related benchmarks have been added or updated, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size
A src/number/clamp.ts 146

@aleclarson aleclarson added the new feature This PR adds a new function or extends an existing one label Jul 13, 2024
@aleclarson aleclarson merged commit 7f4a449 into main Jul 13, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This PR adds a new function or extends an existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_.clamp doesn't check lower vs. upper bounds
2 participants