# num-parser

> Parse numbers in ExpressJS requests.

Latest version **1.1.0** (published 2018-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install num-parser
pnpm add num-parser
yarn add num-parser
bun add num-parser
```

## 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.1.0 |
| Published | 2018-04-16 |
| First published | 2017-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Noah Passalacqua |
| Maintainers | passabilities |
| Keywords | expressjs, number, parser, middleware, javascript, nodejs |

## Links

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

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## 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

- 1.1.0 (latest) — 2018-04-16
- 1.0.4 — 2018-04-11
- 1.0.3 — 2017-06-02
- 1.0.2 — 2017-06-02
- 1.0.1 — 2017-06-02
- 1.0.0 — 2017-06-02

## README

# num-parser [![npm](https://img.shields.io/npm/v/num-parser.svg)](https://www.npmjs.com/package/num-parser)

Parse numbers in ExpressJS requests.

## Installation

    npm i num-parser --save


## Usage

The module will parse all numbers in `req.query`, `req.params`, and `req.body`.

Also works with floating points.

To work with `req.body` you need to add after [body-parser](https://github.com/expressjs/body-parser):

```javascript
const bodyParser = require('body-parser')
const numParser = require('num-parser')

app.use(bodyParser.json())
app.use(numParser)

// ?a=1&b[c]=tw0&b[d]=3.5
app.use('/', (req, res) => {
  console.log(req.query)
  // => { a: 1, b: { c: 'tw0', d: 3.5 } }
})
```

NOTE: I've had problems having it as a global middleware to work with `req.params`. If it's not working for you, try putting the middleware in for each route:

```javascript
// ?a=1&b[c]=tw0&b[d]=3.5
app.use('/', numParser, (req, res) => {
  console.log(req.query)
  // => { a: 1, b: { c: 'tw0', d: 3.5 } }
})
```

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