Package Exports
- convert-string-to-number
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (convert-string-to-number) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
convert-string-to-number
Convert an array to a csv format
Table of Contents
Why?
I needed a simple way to parse string numbers to its matching numerical value, for parsing csv formatted files.
Installation
$ npm i convert-string-to-number -Sor
$ yarn add convert-string-to-numberFunctions
Take a look into the usage section for a detailed example.
convertStringToNumber
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.
const int = convertStringToNumber('2'); // => 2
const float = convertStringToNumber('2.2'); // => 2.2
const notANumber = convertStringToNumber('franz'); // => NaNParameters
- value: a string
Usage
An example how to use it.
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'); // => NaNLicense
MIT © Lukas Aichbauer