parse-numeric
Convert numeric strings into Numbers (or return the original value).
Table of Contents
1. Install
npm i parse-numeric
2. Usage
Test parse-numeric in your Web browser on RunKit .
Pass any String
of valid JavaScript Number
notation
to return either an integer or floating point Number
.
-
;// 12.3 => 12.3
-
;// 123 => 123
-
;// 0b11 => 3
-
;// 0o11 => 9
-
;// 0x11 => 17
-
;// 123e-1 => 12.3
If the parameter cannot convert to a Number
, parseNumeric
returns the
original value.
;// => Rainbows ;// => '' ;// => null ;// => undefined
3. API
parseNumeric
3.1. A function that will return either a Number
or the original value.
parseNumeric.isNumeric
3.2. A convenience function that evaluates whether a value could be numeric.
4. Maintainers
5. Contributing
We gratefully accept Pull Requests.
Please review the CONTRIBUTING guidelines and join in.