# is-natural-number

> Check if a value is a natural number

Latest version **4.0.1** (published 2016-05-16) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2016-05-16 |
| First published | 2014-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/is-natural-number) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | number, natural, check, int, integer, math, mathematics, range, browser, client-side |

## Links

- npm: https://www.npmjs.com/package/is-natural-number
- Repository: https://github.com/shinnn/is-natural-number.js
- Homepage: https://github.com/shinnn/is-natural-number.js#readme
- Issues: https://github.com/shinnn/is-natural-number.js/issues
- npm.io page: https://npm.io/package/is-natural-number

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 4.0.1 (latest) — 2016-05-16
- 4.0.0 — 2016-05-16
- 3.0.0 — 2016-05-16
- 2.1.1 — 2016-05-06
- 2.1.0 — 2016-05-06
- 2.0.0 — 2015-02-15
- 1.0.0 — 2014-11-23

## README

# is-natural-number.js

[![NPM version](https://img.shields.io/npm/v/is-natural-number.svg)](https://www.npmjs.com/package/is-natural-number)
[![Bower version](https://img.shields.io/bower/v/is-natural-number.svg)](https://github.com/shinnn/is-natural-number.js/releases)
[![Build Status](https://travis-ci.org/shinnn/is-natural-number.js.svg)](https://travis-ci.org/shinnn/is-natural-number.js)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/is-natural-number.js.svg)](https://coveralls.io/r/shinnn/is-natural-number.js?branch=master)
[![devDependency Status](https://david-dm.org/shinnn/is-natural-number.js/dev-status.svg)](https://david-dm.org/shinnn/is-natural-number.js#info=devDependencies)

Check if a value is a [natural number](https://wikipedia.org/wiki/Natural_number)

## Installation

### Package managers

#### [npm](https://www.npmjs.com/)

```
npm install is-natural-number
```

#### [Bower](http://bower.io/)

```
bower install is-natural-number
```

#### [Duo](http://duojs.org/)

```javascript
var isNaturalNumber = require('shinnn/is-natural-number.js');
```

### Standalone

[Download the script file directly.](https://raw.githubusercontent.com/shinnn/is-natural-number.js/master/is-natural-number.js)

## API

### isNaturalNumber(*number*, *option*)

*number*: `Number`  
*option*: `Object`  
Return: `Boolean`

It returns `true` if the first argument is one of the natural numbers. If not, or the argument is not a number, it returns `false`.

```javascript
isNaturalNumber(10); //=> true

isNaturalNumber(-10); //=> false
isNaturalNumber(10.5); //=> false
isNaturalNumber(Infinity); //=> false
isNaturalNumber('10'); //=> false
```

*Check [the test](./test.js) for more detailed specifications.*

#### option.includeZero

Type: `Boolean`
Default: `false`

By default the number `0` is not regarded as a natural number.

Setting this option `true` makes `0` regarded as a natural number.

```javascript
isNaturalNumber(0); //=> false
isNaturalNumber(0, {includeZero: true}); //=> true
```

## License

Copyright (c) 2014 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn)

Licensed under [the MIT License](./LICENSE).

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