@sollentson/is-odd
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

isOdd Function

Bundlephobia

You can check the performance in my repository or write your own tests In my case it came out to 1 million iterations: isOdd.png

The isOdd function is a JavaScript utility that determines whether a given number is odd. It performs the following checks before returning the result:

  1. Validates that the input is a number.
  2. Ensures that the number is an integer.
  3. 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 odd, and returns true if it is, and false if it's even.

Usage

The isOdd function can be used as follows:

import { isOdd } from '@sollentson/is-odd';

console.log(isOdd(3)); // Output: true
console.log(isOdd(4)); // Output: false

Installation

You can install the @sollentson/is-odd package using npm:

$ npm install @sollentson/is-odd

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! sollentson@gmail.com

Package Sidebar

Install

npm i @sollentson/is-odd

Weekly Downloads

2

Version

1.0.7

License

MIT

Unpacked Size

3.96 kB

Total Files

5

Last publish

Collaborators

  • sollentson