npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

is-number-checker

v1.0.4

Published

An utility to check if a value is a number (allowing string numbers optionally).

Readme

is-number-checker NPM version License: MIT NPM total downloads

A lightweight utility to check if a given value is a number (with optional support for numeric strings).


🚀 Features

  • Zero dependencies: Lightweight and easy to integrate.
  • Flexible type-checking: Allows strict number validation or optional support for numeric strings.
  • Handles edge cases: Works correctly with Object.create(null), number objects (new Number()), and whitespace-trimmed strings.
  • Cross-platform: Works in Node.js, browsers, and other JavaScript environments.
  • ESM and CJS support: Fully compatible with modern module systems.

📦 Installation

You can install is-number-checker using your favorite package manager:

# Using pnpm
pnpm add is-number-checker

# Using npm
npm install is-number-checker

# Using yarn
yarn add is-number-checker

🌟 Usage

Here's how to use the library in your project:

Import the library

// CommonJS
const isNumber = require('is-number-checker');

// ES Modules
import isNumber from 'is-number-checker';

Basic example

console.log(isNumber(123)); // true
console.log(isNumber(-45.67)); // true
console.log(isNumber(NaN)); // false
console.log(isNumber(Infinity)); // false
console.log(isNumber(null)); // false
console.log(isNumber(undefined)); // false

// By default, string numbers are not considered valid
console.log(isNumber("123")); // false

// Allowing string numbers
console.log(isNumber("123", true)); // true
console.log(isNumber(" 3.14 ", true)); // true
console.log(isNumber("hello", true)); // false
console.log(isNumber("", true)); // false

🔧 API

isNumber(value)

Checks if the given value is a number.

Parameters

  • value (any): The value to check.
  • allowStringNumbers (boolean, optional, default: false): Whether to accept numeric strings as valid numbers.The value to check.

Returns

  • boolean: Returns true if value is a valid number; otherwise, false.

🛠️ Development

If you want to contribute or run the project locally, follow these steps:

Clone the repository

git clone https://github.com/angelabenavente/is-number-checker.git
cd is-number-checker

Install dependencies

npm install

Run tests

npm run test

Lint the code

npm run eslint

🧪 Testing

This project uses Jest for testing. To run the test suite, simply use:

npm run test

Example output:

PASS  ./index.test.js
✓ returns true for valid numbers (10 ms)
✓ returns false for non-number values
✓ handles string numbers correctly when allowed
...

Feel free to add more test cases in the test file.

🔄 Changelog

See CHANGELOG.md for a detailed history of changes.


💡 Contributing

Contributions are welcome! If you'd like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a clear description of the changes.

See CONTRIBUTING.md for more details.


📜 License

This project is licensed under the MIT License. Created with ❤️ by Ángela Benavente.


🌍 Links