# as-number

> typeof number, or use a default

Latest version **1.0.0** (published 2014-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install as-number
pnpm add as-number
yarn add as-number
bun add as-number
```

## 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.0 |
| Published | 2014-09-17 |
| First published | 2014-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | typeof, type, of, is, number, num, default, arg, arguments, opt, opts, options |

## Links

- npm: https://www.npmjs.com/package/as-number
- Repository: https://github.com/mattdesl/as-number
- Issues: https://github.com/mattdesl/as-number/issues
- npm.io page: https://npm.io/package/as-number

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-09-17

## README

# as-number

[![frozen](http://badges.github.io/stability-badges/dist/frozen.svg)](http://github.com/badges/stability-badges)

Tiny function that returns the given number, or a default value if `typeof !== 'number'`. If no default is given, returns 0.

```js
var number = require('as-number')

var num = number(arg0, 25) //default to 25
var num2 = number(arg1)    //default to zero
```

## Usage

[![NPM](https://nodei.co/npm/as-number.png)](https://nodei.co/npm/as-number/)

#### `number(value[, default])`

If `value` is `typeof === 'number'`, then it simply returns `value` unchanged. Otherwise, it will return `default` if it is also a number, or zero. 

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/as-number/blob/master/LICENSE.md) for details.

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