An open API service indexing awesome lists of open source software.

https://github.com/caiogondim/parse-price.js

:dollar: Returns a Number from a localized price string.
https://github.com/caiogondim/parse-price.js

Last synced: about 1 month ago
JSON representation

:dollar: Returns a Number from a localized price string.

Awesome Lists containing this project

README

        

# parse-price
Travis CI [![codecov](https://codecov.io/gh/caiogondim/parse-price.js/branch/master/graph/badge.svg)](https://codecov.io/gh/caiogondim/parse-price.js) dependencies status lib size

Returns a `Number` from a localized price string.

## Installation

```shell
npm install --save parse-price
```

## Usage

Receives a string (price) as input and returns a `Number` (or `NaN`) as output.

```js
var parsePrice = require('parse-price')

parsePrice('€1.234,56') // => 1234.56
parsePrice('US$ 1.234,56') // => 1234.56
parsePrice('£1,234.56') // => 1234.56
parsePrice('R$1.234,56') // => 1234.56
parsePrice('1 234,56 руб') // => 1234.56
parsePrice('1,234.56 ₪') // => 1234.56
```

---

[caiogondim.com](https://caiogondim.com)  · 
GitHub [@caiogondim](https://github.com/caiogondim)  · 
Twitter [@caio_gondim](https://twitter.com/caio_gondim)