sfcode
An Online Competing and Development Environment
|
Contributing
Returns true if the value is a finite number.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
In JavaScript, it's not always as straightforward as it should be to reliably check if a value is a number. It's common for devs to use +
, -
, or Number()
to cast a string value to a number (for example, when values are returned from user input, regex matches, parsers, etc). But there are many non-intuitive edge cases that yield unexpected results:
This library offers a performant way to smooth out edge cases like these.
See the tests for more examples.
Everything else is false, as you would expect:
.isFinite
if it exists.Breaking changes
instanceof Number
and instanceof String
As with all benchmarks, take these with a grain of salt. See the benchmarks for more detail.
<details>
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
</details>
<details>
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
</details>
<details>
Building docs
_(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)_
To generate the readme, run the following command:
</details>
You might also be interested in these projects:
Object
constructor. | homepagetrue
if the value is a primitive. | homepageCommits | Contributor |
---|---|
49 | jonschlinkert |
5 | charlike-old |
1 | benaadams |
1 | realityking |
Jon Schlinkert
Copyright © 2018, Jon Schlinkert. Released under the [MIT License](LICENSE).
This file was generated by verb-generate-readme, v0.6.0, on June 15, 2018.