fast-isnumeric
The fast way to check if a JS object is numeric
Last updated 8 months ago by archmoj .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fast-isnumeric 
SYNC missed versions from official npm registry.

fast-isnumeric

The fast way to check if a JS object is numeric

Install

npm install fast-isnumeric

API

var isNumeric = require('fast-isnumeric');

isNumeric(/* any JS object */);

How fast

Run comparison on jsperf: http://jsperf.com/isnumeric-jquery-and-alternate/5

Warning

Please look up the test cases in test.js before using this module.

Most importantly, fast-isnumeric returns false on number and string constructors. That is, isNumeric(new Number(1)) and isNumeric(new String('1')) are false.

Tests

Test locally with karma:

npm test

Why?

In plotly's javascript graphing library plotly.js numerical objects must be accounted for in numerous hot code paths. Inspired by Jon Schlinkert's is-number, fast-isnumeric is significantly simplified and sped up by ignoring number and string constructors.

Author

Alex Johnson | https://github.com/alexcjohnson

License

Copyright (c) 2015 Alex Johnson Released under the MIT license.

Current Tags

  • 1.1.4                                ...           latest (8 months ago)

6 Versions

  • 1.1.4                                ...           8 months ago
  • 1.1.3                                ...           a year ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago

Copyright 2014 - 2016 © taobao.org |