Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

isnumeric

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isnumeric

Determine if a JavaScript object is numeric

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
209K
decreased by-2.01%
Maintainers
1
Weekly downloads
 
Created
Source

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();

Keywords

FAQs

Package last updated on 10 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc