Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

oddguard

rigial339MIT1.0.3TypeScript support: included

Utility functions to check if a value is an odd integer within JavaScript's safe range, and to validate whether a value (number or string) is a finite number for input parsing, regex matches, and user validation.

array, cast, check, coerce, coercion, count, even, filter, finite, integer, is, is-nan, is-num, is-number, isfinite, isnan, istype, kind, math, nan, num, number, numeric, odd, parseFloat, parseInt, string, test, type, typeof, value

readme

oddguard NPM version NPM monthly downloads NPM total downloads

Returns true if the given number is an odd integer that does not exceed JavaScript’s Number.MAX_SAFE_INTEGER.

Returns true if a number or string value is a finite number. Useful for regex matches, parsing, user input, and validation.

Please consider following this project's author, M R Kishore Kumar, and consider starring the project to show your :heart: and support.

Install

Install with npm:

$  npm install --save oddguard

Usage

Works with strings or numbers.


const { isOdd, isNumber } = require('oddguard');

// Odd checks

console.log(isOdd('1')); //=> true

console.log(isOdd('3')); //=> true

console.log(isOdd(0)); //=> false

console.log(isOdd(2)); //=> false

// Number validation

console.log(isNumber(42)); //=> true

console.log(isNumber('3.14')); //=> true

console.log(isNumber('foo')); //=> false

console.log(isNumber(NaN)); //=> false

About

<summary>Contributing</summary>

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

<summary>Running Tests</summary>

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$  npm install && npm test

Author

M R Kishore Kumar

License

Copyright © 2025, Rigial.

Released under the MIT License.