0.0.2-2 • Published 3 years ago
@dopamyn/price-extract v0.0.2-2
Extract Price from String
Performant way to extract price amount and metadatas (currency, decimal & thousands separator) from any string.
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))
);