Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pruvonet/price-extractor
Given a price string, extract the price and currency code
https://github.com/pruvonet/price-extractor
curr currency extract extractor javascript node parser price
Last synced: about 2 months ago
JSON representation
Given a price string, extract the price and currency code
- Host: GitHub
- URL: https://github.com/pruvonet/price-extractor
- Owner: PruvoNet
- License: gpl-3.0
- Created: 2018-02-13T08:56:07.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-09-27T22:36:39.000Z (over 1 year ago)
- Last Synced: 2024-11-11T21:53:20.432Z (3 months ago)
- Topics: curr, currency, extract, extractor, javascript, node, parser, price
- Language: TypeScript
- Size: 169 KB
- Stars: 10
- Watchers: 5
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Npm Version](https://img.shields.io/npm/v/price-extractor.svg?style=popout)](https://www.npmjs.com/package/price-extractor)
[![node](https://img.shields.io/node/v-lts/price-extractor)](https://www.npmjs.com/package/price-extractor)
[![Build status](https://github.com/PruvoNet/price-extractor/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/PruvoNet/price-extractor/actions/workflows/ci.yml)
[![Test Coverage](https://api.codeclimate.com/v1/badges/83a4b9446725afb8f6ef/test_coverage)](https://codeclimate.com/github/PruvoNet/price-extractor/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/83a4b9446725afb8f6ef/maintainability)](https://codeclimate.com/github/PruvoNet/price-extractor/maintainability)
[![Known Vulnerabilities](https://snyk.io/test/github/PruvoNet/price-extractor/badge.svg?targetFile=package.json)](https://snyk.io/test/github/PruvoNet/price-extractor?targetFile=package.json)# price-extractor
A small library for parsing price strings in order to extract the price as a number and the currency code of the price.
The library can handle all kinds of thousands and cents delimiters, as well as all currency native symbols and unicodes.## Installation
```sh
npm install price-extractor
```
Or
```sh
yarn add price-extractor
```## Examples
```typescript
import {searchPriceAndCode} from 'price-extractor';
console.dir(searchPriceAndCode('99,01€')); // { price: 99.01, code: 'EUR' }
console.dir(searchPriceAndCode('ARS 1,647.86')); // { price: 1647.86, code: 'ARS' }
console.dir(searchPriceAndCode('1.958,43 NOK')); // { price: 1958.43, code: 'NOK' }
console.dir(searchPriceAndCode('¥732.62')); // { price: 732.62, code: 'JPY' }
console.dir(searchPriceAndCode('2\'425.64 CHF')); // { price: 2425.64, code: 'CHF' }
```