# is-number-strict

> Tiny lib to check if passed argument is strictly number. Strings will not pass!

Latest version **1.0.9** (published 2022-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-number-strict
pnpm add is-number-strict
yarn add is-number-strict
bun add is-number-strict
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2022-11-24 |
| First published | 2018-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 106.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Drag13 |
| Maintainers | drag13 |
| Keywords | number, typecheck, typeof, types, NaN |

## Links

- npm: https://www.npmjs.com/package/is-number-strict
- npm.io page: https://npm.io/package/is-number-strict

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2022-11-24
- 1.0.8 — 2022-04-02
- 1.0.7 — 2022-02-14
- 1.0.6 — 2022-01-25
- 1.0.5 — 2022-01-14
- 1.0.4 — 2021-09-18
- 1.0.3 — 2021-05-08
- 1.0.2 — 2020-06-23
- 1.0.1 — 2018-12-23
- 1.0.0 — 2018-12-23
- 0.1.1 — 2018-07-18
- 0.3.0 — 2018-07-17
- 0.1.0 — 2018-07-17

## README

[![StandsWithUkraine](https://github.com/Drag13/drag13.github.io/blob/development/swu.PNG)
](https://savelife.in.ua/en/donate/)

# IsNumberStrict - check if something is a number

[![Weekly loads](https://img.shields.io/npm/dm/is-number-strict)](https://img.shields.io/npm/dm/is-number-strict)
[![Minzipped size](https://img.shields.io/bundlephobia/minzip/is-number-strict)](https://img.shields.io/bundlephobia/minzip/is-number-strict)
[![Build Status](https://travis-ci.org/Drag13/IsNumberStrict.svg?branch=master)](https://travis-ci.org/Drag13/IsNumberStrict)
[![codecov](https://codecov.io/gh/Drag13/isnumberstrict/branch/master/graph/badge.svg)](https://codecov.io/gh/Drag13/isnumberstrict)
[![TypeSCript](https://img.shields.io/badge/TypeScript-Ready-brightgreen.svg)](https://github.com/Drag13/IsNumberStrict)
[![GitHub license](https://img.shields.io/github/license/Drag13/WhenDo.svg)](https://github.com/Drag13/IsNumberStrict/blob/master/LICENSE)

Designed to strictly check if the value is a number. Works with Number objects, hex, and so on. Returns `false` for `string` and other not numbers like `{}`, `undefined`, `NaN`

## Install

```cmd
npm i is-number-strict
```

## Usage

JavaScript with require syntax

```javascript
const isNumber = require('is-number-strict').default;

console.assert(isNumber(5));
console.assert(!isNumber('5'));
```

JavaScript with import syntax

```javascript
import isNumber from "is-number-strict";

console.assert(isNumber(5));
console.assert(!isNumber('5'));
```

## What problem it solves

This tiny lib tries to make type assertion little bit more predictable and remove NaN from your calculations.

```javascript
typeof new Number(42);
> 'object'
```

But it is working as good old number

```javascript
new Number(5) * new Number(6);
> 30
```

So:

```javascript
isNumberStrict(new Number(5));
> true
```

But:

```javascript
isNumberStrict('5');
> false
```

And

```javascript
isNumberStrict(NaN);
> false
```

> Why didn't you treat '5' as a number? '5' + 5 = 10!
Yes, but 5 + '5' = '55' and 5 * '5' = NaN. I don't want to see NaN or '55' in my calculations.

So if you want to have more predictable type checking - check my tests and welcome!

## Some wired cases

> Why do you treat new Number([]) as a number?

Because JS will evaluate it to 0, and 0 is number.

> Why do you treat new number({}) as not a number?

Because JS will evaluate it to  NaN and NaN is not a number according to my purposes.

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