1.0.10 • Published 3 years ago

asg-ktb-fe-02 v1.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

asg-ktb-fe-02

npm Travis branch Codecov branch

Convert a string to its numerical value (float or integer)

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 asg-ktb-fe-02 -S

or

$ yarn add asg-ktb-fe-02

Functions

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 number = convertStringToNumber(value);
Parameters
  • value: a string

Usage

An example how to use it.

const { convertStringToNumber } = require('asg-ktb-fe-02'); // named export
const converter = require('asg-ktb-fe-02'); // default export

const int = convertStringToNumber('2'); // => 2
const float = converter('2.2'); // => 2.2
const notANumber = converter('franz'); // => NaN

License

MIT © AsG

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.6

3 years ago

1.0.7

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago