Convert a string to its numerical value (float or integer)
npm install convert-string-to-number


> Convert a string to its numerical value (float or integer)
* Why?
* Installation
* Functions
* Usage
* License
I needed a simple way to parse string numbers to its matching numerical value, for parsing csv formatted files.
``sh`
$ npm i convert-string-to-number -S
or
`sh`
$ yarn add convert-string-to-number
Take a look into the usage section for a detailed example.
> Note: you can also use the default export.
This function converts a string to its numerical value (float, int, or NaN).
#### Syntax
Returns a number or NaN.
`js`
const number = convertStringToNumber(value);
##### Parameters
* value: a string
An example how to use it.
`js
const { convertStringToNumber } = require('convert-string-to-number'); // named export
const converter = require('convert-string-to-number'); // default export
const int = convertStringToNumber('2'); // => 2
const float = converter('2.2'); // => 2.2
const notANumber = converter('franz'); // => NaN
``
MIT © Lukas Aichbauer