isnumeric
Determine if a JavaScript object is numeric
Last updated 7 years ago by leecrossley .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install isnumeric 
SYNC missed versions from official npm registry.

isNumeric Build Status npm version devDependency Status

Determine if a JavaScript object is numeric.

Using npm

npm install isnumeric

To then include isnumeric in your node app:

var isNumeric = require("isnumeric");

Direct dependency

Download the minified version here, reference the js file and isNumeric will become a global variable.

Truthy test cases

Integers

expect(isNumeric(1)).toBeTruthy();
expect(isNumeric(-1)).toBeTruthy();
expect(isNumeric(0)).toBeTruthy();
expect(isNumeric("1")).toBeTruthy();
expect(isNumeric("-1")).toBeTruthy();
expect(isNumeric("0")).toBeTruthy();
expect(isNumeric("1.")).toBeTruthy();

Max / min numbers

expect(isNumeric(Number.MAX_VALUE)).toBeTruthy();
expect(isNumeric(Number.MIN_VALUE)).toBeTruthy();

Octals

expect(isNumeric(0144)).toBeTruthy();
expect(isNumeric("0144")).toBeTruthy();

Hexadecimals

expect(isNumeric(0xFF)).toBeTruthy();
expect(isNumeric("0xFF")).toBeTruthy();

Floating-points

expect(isNumeric(1.1)).toBeTruthy();
expect(isNumeric(0.1)).toBeTruthy();
expect(isNumeric(-1.1)).toBeTruthy();
expect(isNumeric(-0.1)).toBeTruthy();
expect(isNumeric("1.1")).toBeTruthy();
expect(isNumeric("0.1")).toBeTruthy();
expect(isNumeric("-1.1")).toBeTruthy();
expect(isNumeric("-0.1")).toBeTruthy();
expect(isNumeric(".1")).toBeTruthy();

Exponentials

expect(isNumeric(3e5)).toBeTruthy();
expect(isNumeric(123e-2)).toBeTruthy();
expect(isNumeric("3e5")).toBeTruthy();
expect(isNumeric("123e-2")).toBeTruthy();

Decimal commas

expect(isNumeric(1,1)).toBeTruthy();
expect(isNumeric("1,1")).toBeTruthy();

Current Tags

  • 0.3.3                                ...           latest (7 years ago)

19 Versions

  • 0.3.3                                ...           7 years ago
  • 0.3.2                                ...           8 years ago
  • 0.3.1                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.0                                ...           10 years ago
  • 0.1.5                                ...           10 years ago
  • 0.1.4                                ...           10 years ago
  • 0.1.3                                ...           10 years ago
  • 0.1.2                                ...           10 years ago
  • 0.1.1                                ...           10 years ago
  • 0.0.10                                ...           11 years ago
  • 0.0.9                                ...           11 years ago
  • 0.0.7                                ...           11 years ago
  • 0.0.6                                ...           11 years ago
  • 0.0.5                                ...           11 years ago
  • 0.0.4                                ...           11 years ago
  • 0.0.3                                ...           11 years ago
  • 0.0.2                                ...           11 years ago
  • 0.0.1                                ...           11 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (6)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE