# num-or-not

> Check for a valid Number value.

Latest version **1.0.1** (published 2015-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install num-or-not
pnpm add num-or-not
yarn add num-or-not
bun add num-or-not
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-12-10 |
| First published | 2015-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michael Wuergler |
| Maintainers | radiovisual |
| Keywords | Number, num, valid, validate, check, undefined, verify |

## Links

- npm: https://www.npmjs.com/package/num-or-not
- Repository: https://github.com/radiovisual/num-or-not
- Homepage: https://github.com/radiovisual/num-or-not#readme
- Issues: https://github.com/radiovisual/num-or-not/issues
- npm.io page: https://npm.io/package/num-or-not

## Dependencies (1)

- [trim](https://npm.io/package/trim.md) 0.0.1

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-12-10
- 1.0.0 — 2015-12-04

## README

# num-or-not [![Build Status](https://travis-ci.org/radiovisual/num-or-not.svg)](https://travis-ci.org/radiovisual/num-or-not)
> Check for a valid Number value.

Numbers, and values that can be cast or evaluated to numbers will return `true`.

All other values will return `false`.

## Installation

```
$ npm install --save num-or-not
```

## Usage

```js
const isNumber = require('num-or-not');

// Integers
isNumber(5);            // => true
isNumber(-5);           // => true
isNumber('5');          // => true
isNumber('-5');         // => true

// Floats (Decimal & Comma)
isNumber(5.0);          // => true
isNumber('5.0');        // => true
isNumber('5,0');        // => true

// Octal (ES6)
isNumber(0o144);        // => true
isNumber(0O144);        // => true
isNumber('0o144');      // => true
isNumber('0O144');      // => true

// Binary (ES6)
isNumber(0b0);          // => true
isNumber('0b0');        // => true
   
// Hexadecimal
isNumber(0xFF);         // => true    
isNumber('0xFF');       // => true

// Exponential
isNumber(6e3);          // => true
isNumber(12e-2);        // => true
isNumber('6e3');        // => true
isNumber('12e-2');      // => true

// Currency Values
isNumber('12,456,789'); // => true
isNumber('45,678.123'); // => true

// "Evaluates to Int" values
isNumber(+'');          // => true
isNumber(+[]);          // => true
isNumber(+[0]);         // => true
isNumber(+true);        // => true
isNumber(+new Date);    // => true
```

## Known Limitations

-  These binary and octal formats are **only supported in ES6** environments:
 - Binary: `0b0`
 - Octal: `0o144` & `0O144`
 
- In order to support numbers with commas or decimals (currencies, Dewey Decimal System, etc), some unique values can pass as valid numbers (see [Issue #1](https://github.com/radiovisual/num-or-not/issues/1)):
 - `1,2,3.4.5`
 - `1,2,3,4.5`
 
- Open a pull request or issue if you think we need tighter control over these limitations.
 
 
## Why?

Why do we need another open source number validator in Javascript? **We don't**, but I wanted one to help keep me accountable of the data type nuances in JS.
 
## License

MIT @ [Michael Wuergler](http://numetriclabs.com/)

---
_Source: https://npm.io/package/num-or-not · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
