# numero

> A stricter `parseInt` and `parseFloat`.

Latest version **0.1.1** (published 2014-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install numero
pnpm add numero
yarn add numero
bun add numero
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2014-12-30 |
| First published | 2014-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Lim Yuan Qing |
| Maintainers | yuanqing |
| Keywords | float, integer, number, numeric, parse, string |

## Links

- npm: https://www.npmjs.com/package/numero
- Repository: https://github.com/yuanqing/numero
- Issues: https://github.com/yuanqing/numero/issues
- npm.io page: https://npm.io/package/numero

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2014-12-30
- 0.1.0 — 2014-12-30

## README

# Numero.js [![npm Version](http://img.shields.io/npm/v/numero.svg?style=flat)](https://www.npmjs.org/package/numero) [![Build Status](https://img.shields.io/travis/yuanqing/numero.svg?style=flat)](https://travis-ci.org/yuanqing/numero) [![Coverage Status](https://img.shields.io/coveralls/yuanqing/numero.svg?style=flat)](https://coveralls.io/r/yuanqing/numero)

> A stricter `parseInt` and `parseFloat`.

## Usage

```js
numero.parseInt(42);      // 42
numero.parseInt('42');    // 42
numero.parseInt('42 ');   // 42
numero.parseInt(3.14);    // null
numero.parseInt('3.14');  // null
numero.parseInt(' 3.14'); // null

numero.parseFloat(42);      // 42
numero.parseFloat('42');    // 42
numero.parseFloat('42 ');   // 42
numero.parseFloat(3.14);    // 3.14
numero.parseFloat('3.14');  // 3.14
numero.parseFloat(' 3.14'); // 3.14
```

1. `null` is returned if `x` cannot be parsed to an integer/float.

2. An integer is also a float.

3. `x` can have trailing/leading whitespace.

Numero is stricter than the native `parseInt` and `parseFloat` in that extraneous characters are not allowed. For example:

```js
parseInt('42foo', 10);    // 42
numero.parseInt('42foo'); // null

parseFloat('3.14foo');        // 3.14
numero.parseFloat('3.14foo'); // null
```

Numero can also handle numbers in their octal and hexadecimal representations, and negative numbers too:

```js
numero.parseInt('052');     // 42
numero.parseFloat('-0x2a'); // -42
```

[Check the tests.](https://github.com/yuanqing/numero/blob/master/test)

## API

### numero.isInt(x)

Returns `true` if `x` can be parsed to an integer. Alias: `isInteger`

### numero.parseInt(x)

Returns an integer, or `null` if `x` cannot be parsed to an integer. Alias: `parseInteger`.

### numero.isFloat(x)

Returns `true` if `x` can be parsed to a float.

### numero.parseFloat(x)

Returns a float, or `null` if `x` cannot be parsed to a float.

## Installation

Install via [npm](https://www.npmjs.org/):

```bash
$ npm i --save numero
```

## Changelog

- 0.1.0
  - Initial release

## License

[MIT license](https://github.com/yuanqing/numero/blob/master/LICENSE)

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