| 1 |
Number |
| 2 |
=== |
| 3 |
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependencies][dependencies-image]][dependencies-url] |
| 4 |
|
| 5 |
> Validates if a value is a number. |
| 6 |
|
| 7 |
|
| 8 |
## Installation |
| 9 |
|
| 10 |
``` bash |
| 11 |
$ npm install validate.io-number |
| 12 |
``` |
| 13 |
|
| 14 |
For use in the browser, use [browserify](https://github.com/substack/node-browserify). |
| 15 |
|
| 16 |
|
| 17 |
## Usage |
| 18 |
|
| 19 |
``` javascript |
| 20 |
var isNumber = require( 'validate.io-number' ); |
| 21 |
``` |
| 22 |
|
| 23 |
#### isNumber( value ) |
| 24 |
|
| 25 |
Validates if a `value` is a `number`. |
| 26 |
|
| 27 |
``` javascript |
| 28 |
var value = Math.PI; |
| 29 |
|
| 30 |
var bool = isNumber( value ); |
| 31 |
// returns true |
| 32 |
``` |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
## Examples |
| 37 |
|
| 38 |
``` javascript |
| 39 |
console.log( isNumber( 5 ) ); |
| 40 |
// returns true |
| 41 |
|
| 42 |
console.log( isNumber( new Number( 5 ) ) ); |
| 43 |
// returns true |
| 44 |
|
| 45 |
console.log( isNumber( NaN ) ); |
| 46 |
// returns false |
| 47 |
``` |
| 48 |
|
| 49 |
To run the example code from the top-level application directory, |
| 50 |
|
| 51 |
``` bash |
| 52 |
$ node ./examples/index.js |
| 53 |
``` |
| 54 |
|
| 55 |
|
| 56 |
## Tests |
| 57 |
|
| 58 |
### Unit |
| 59 |
|
| 60 |
Unit tests use the [Mocha](http://mochajs.org) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory: |
| 61 |
|
| 62 |
``` bash |
| 63 |
$ make test |
| 64 |
``` |
| 65 |
|
| 66 |
All new feature development should have corresponding unit tests to validate correct functionality. |
| 67 |
|
| 68 |
|
| 69 |
### Test Coverage |
| 70 |
|
| 71 |
This repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory: |
| 72 |
|
| 73 |
``` bash |
| 74 |
$ make test-cov |
| 75 |
``` |
| 76 |
|
| 77 |
Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report, |
| 78 |
|
| 79 |
``` bash |
| 80 |
$ make view-cov |
| 81 |
``` |
| 82 |
|
| 83 |
|
| 84 |
--- |
| 85 |
## License |
| 86 |
|
| 87 |
[MIT license](http://opensource.org/licenses/MIT). |
| 88 |
|
| 89 |
|
| 90 |
## Copyright |
| 91 |
|
| 92 |
Copyright © 2014. Athan Reines. |
| 93 |
|
| 94 |
|
| 95 |
[npm-image]: http://img.shields.io/npm/v/validate.io-number.svg |
| 96 |
[npm-url]: https://npmjs.org/package/validate.io-number |
| 97 |
|
| 98 |
[travis-image]: http://img.shields.io/travis/validate-io/number/master.svg |
| 99 |
[travis-url]: https://travis-ci.org/validate-io/number |
| 100 |
|
| 101 |
[coveralls-image]: https://img.shields.io/coveralls/validate-io/number/master.svg |
| 102 |
[coveralls-url]: https://coveralls.io/r/validate-io/number?branch=master |
| 103 |
|
| 104 |
[dependencies-image]: http://img.shields.io/david/validate-io/number.svg |
| 105 |
[dependencies-url]: https://david-dm.org/validate-io/number |
| 106 |
|
| 107 |
[dev-dependencies-image]: http://img.shields.io/david/dev/validate-io/number.svg |
| 108 |
[dev-dependencies-url]: https://david-dm.org/dev/validate-io/number |
| 109 |
|
| 110 |
[github-issues-image]: http://img.shields.io/github/issues/validate-io/number.svg |
| 111 |
[github-issues-url]: https://github.com/validate-io/number/issues |