New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

parse-money

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-money

Extract money from text (number and currency detection)

latest
Source
npmnpm
Version
1.0.12
Version published
Weekly downloads
505
0.2%
Maintainers
1
Weekly downloads
 
Created
Source

parse-money

Travis CI

Extract money from text (number and currency detection)

Returns the amount as Number and the currency as string from a text that contains money.

Installation

npm install --save parse-money
yarn add parse-money

Usage

Pass a string to extract money from.

import parseMoney from 'parse-money';

parseMoney('€1.234,56') // => { amount: 1234.56, currency: 'EUR' }
parseMoney('US$ 1.234,56') // => { amount: 1234.56, currency: 'USD' }
parseMoney('$1.234,56') // => { amount: 1234.56, currency: 'USD' }
parseMoney('1.234,56 US dollars') // => { amount: 1234.56, currency: 'USD' }
parseMoney('£1,234.56') // => { amount: 1234.56, currency: 'GBP' }
parseMoney('R$1.234,56') // => { amount: 1234.56, currency: 'BRL' }
parseMoney('1 234,56 руб') // => { amount: 1234.56, currency: 'RUB' }
parseMoney('1,234.56 ₪') // => { amount: 1234.56, currency: 'ILS' }
parseMoney('123,456.78 lei') // => { amount: 123456.78, currency: 'RON' }
parseMoney('123,45 lei') // => { amount: 123.45, currency: 'RON' }
parseMoney('some text before 123,45 lei and some text after') // => { amount: 123.45, currency: 'RON' }

Typings

type Money = {
  currency: Currency;
  amount: number;
}

type Currency = 'USD' | 'GBP' | 'EUR' | 'BRL' | 'RUB' | 'ILS' | 'RON';

GitHub @mindtricksdev  ·  Twitter @mindtricksdev

Keywords

parse

FAQs

Package last updated on 21 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts