@saitejashashank/is-even-odd
v1.0.0
Published
Tiny zero-dependency helpers to check if an integer is even or odd. Works in React Native, Node and the browser.
Maintainers
Readme
@yourusername/is-even-odd
Zero-dependency helpers to check integer parity. Pure JavaScript — no native modules, so it works in React Native, Node and the browser without linking or pods.
Install
npm install @yourusername/is-even-oddUsage
import { isEven, isOdd } from '@yourusername/is-even-odd';
isEven(4); // true
isEven(-3); // false
isOdd(7); // trueBehaviour
Both functions throw a TypeError for anything that isn't a safe integer — floats, NaN, Infinity, non-numbers, and values beyond Number.MAX_SAFE_INTEGER. This is deliberate: 2.5 % 2 is 0.5, which would otherwise be silently reported as odd.
isEven(2.5); // TypeError: Expected an integer, received: 2.5Development
npm install
npm test
npm run buildLicense
MIT
