parse-formatted-number

1.1.1 • Public • Published

parse-formatted-number

Parses a formatted number from a string and returns a number.

Usage

parseFormattedNumber(value[, options])

Parameters

  • value The value you want to parse.
  • options optional object of the following options:
    • decimal string decimal separator character, defaults to ".".

Return value

Number number parsed from the given value. If the value cannot be converted to a number, NaN is returned.

Example

import parseFormattedNumber from 'parse-formatted-number';

parseFormattedNumber('NZD $12,345.60');
// returns 12345.6

parseFormattedNumber('123,45', { decimal: ',' });
// returns 123.45

Dependents (0)

Package Sidebar

Install

npm i parse-formatted-number

Weekly Downloads

5

Version

1.1.1

License

MIT

Unpacked Size

9.85 kB

Total Files

8

Last publish

Collaborators

  • jacobbuck