A JavaScript utility that returns true if a given number is odd and is a valid integer within safe limits.
is-odd is a JavaScript utility library that checks whether a given number is odd. It solves the problem of reliably determining odd/even status while handling edge cases like string inputs and JavaScript's integer safety limits. The library ensures numbers are valid integers that don't exceed MAXIMUM_SAFE_INTEGER before performing the check.
JavaScript developers who need reliable odd/even checking in their applications, particularly those working with user input or data validation where edge cases matter.
Developers choose is-odd because it provides a battle-tested, focused solution with proper edge case handling that's more reliable than writing custom odd/even logic. It's lightweight, well-documented, and part of a family of related mathematical utilities.
I created this in 2014, the year I learned how to program. All of the downloads are from an old version of https://github.com/micromatch/micromatch. I've done a few other things since: https://github.com/jonschlinkert.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Ensures numbers do not exceed MAXIMUM_SAFE_INTEGER, preventing issues with JavaScript's integer precision limits as stated in the README.
Accepts both string and number inputs, simplifying integration with user data or APIs without prior type conversion, demonstrated in the usage examples.
Handles zero, negative numbers, and invalid inputs gracefully, providing reliable results in various scenarios as highlighted in the key features.
As a single-purpose utility with minimal dependencies, it adds negligible overhead to projects, aligning with its minimalist philosophy.
The core functionality can be implemented with a one-line modulo check, making the library unnecessary for projects that prioritize minimal dependencies.
Does not support numbers beyond MAXIMUM_SAFE_INTEGER, which restricts its use in applications dealing with very large integers, as admitted in the description.
The README lacks mention of built-in TypeScript definitions, requiring additional effort for TypeScript users to integrate it seamlessly.