UNPKG

@ealch/oddyssey

Version:

A tiny TypeScript library to check if a number is odd or even โ€” your journey into parity begins here.

73 lines (51 loc) โ€ข 1.57 kB
# ๐ŸŒ€ Oddyssey - it's odd [![npm version](https://img.shields.io/npm/v/%40ealch%2Foddyssey?color=blue&t=1)](https://www.npmjs.com/package/@ealch/oddyssey) [![license](https://img.shields.io/npm/l/%40ealch%2Foddyssey)](./LICENSE.md) [![minzipped size](https://img.shields.io/bundlephobia/minzip/%40ealch%2Foddyssey)](https://bundlephobia.com/package/@ealch/oddyssey) A tiny utility to check if a number is **odd** or **even**. Published as: [`@ealch/oddyssey`](https://www.npmjs.com/package/@ealch/oddyssey) --- ## ๐Ÿ“ฆ Installation ```bash npm install @ealch/oddyssey # or pnpm add @ealch/oddyssey # or yarn add @ealch/oddyssey ``` ## ๐Ÿ“ฆ Usage ```js import { isOdd, isEven } from '@ealch/oddyssey'; console.log(isOdd(3)); // true console.log(isEven(4)); // true console.log(isOdd(0)); // false console.log(isEven(1)); // false ``` ## ๐Ÿง  API **isOdd(value: number): boolean** Returns true if the given number is odd. **isEven(value: number): boolean** Returns true if the given number is even. ## ๐Ÿงช Example ```js import { isEven } from '@ealch/oddyssey'; [1, 2, 3, 4, 5, 6].forEach(n => { console.log(`${n} is even: ${isEven(n) ? 'yes' : 'no'}`); }); ``` **Output:** ```bash 1 is even: no 2 is even: yes 3 is even: no 4 is even: yes 5 is even: no 6 is even: yes ``` ## ๐Ÿงพ Scripts - **`dev`**: Run Vite in dev mode - **`build`**: Build the library (JS bundles + TypeScript types) - **`preview`**: Preview the library build locally - **`prepublishOnly`**: Hook to build before publishing to npm ## ๐Ÿ“„ License MIT ยฉ @ealch