@sollentson/is-even
v1.0.3
Published
Returns true if the given number is odd, and is an integer that does not exceed the JavaScript MAXIMUM_SAFE_INTEGER.
Downloads
2
Maintainers
Readme
isEven Function
You can check the performance in my repository or write your own tests In my case it came out to 1 million iterations:
The isEven
function is a JavaScript utility that determines whether a given number is even. It performs the following checks before returning the result:
- Validates that the input is a number.
- Ensures that the number is an integer.
- Verifies that the number does not exceed the maximum safe integer in JavaScript.
The function then uses a bitwise operation to check if the absolute value of the number is even, and returns true
if it is, and false
if it's odd.
Usage
The isEven
function can be used as follows:
import { isEven } from '@sollentson/is-even';
console.log(isEven(3)); // Output: false
console.log(isEven(4)); // Output: true
Installation
You can install the @sollentson/is-even
package using npm:
$ npm install @sollentson/is-even
License
This function is provided under the MIT License. Please see the LICENSE file for more details.
For any issues or feature requests, please create an issue on the BitBucket repository.
If you have any further questions or need additional information, feel free to ask! [email protected]