0.0.2-2 • Published 3 years ago

@dopamyn/price-extract v0.0.2-2

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

Extract Price from String

Performant way to extract price amount and metadatas (currency, decimal & thousands separator) from any string.

npm

Installation

npm install --save @dopamyn/price-extract

Usage

extractPrice( input: string, details?: boolean = false, debug?: boolean = false ): TPrice | number | null;

Usage example

import extractPrice from '@dopamyn/price-extract';

console.log(
    'Should be ok:',
    ...['1 185,36 €', '$ 1,185,456.36', 'RUB 1185.36', '118536£'].map(v => price(v, false, true))
);

console.log(
    'Should be null:',
    ...['EUR 85,456.3', 'EUR 85,4556.34', '$ 1.185,456.36'].map(v => price(v, false, true))
);
0.0.2-2

3 years ago

0.0.2-1

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago