dynamic-currency-formatter
v1.3.0
Published
realtime dynamic "Real-time Currency Converter" is an intuitive npm package designed to simplify the formatting and conversion of currency values in real-time for both inputs and static outputs. Whether you're building financial applications, e-commerce p
Downloads
107
Readme
dynamic-currency-formatter
A lightweight React and JavaScript utility package for real-time currency formatting and static number-to-currency conversions.
Features
- Dynamic input formatting for forms.
- Format static numbers as currency.
- Strip formatting for calculations.
- Configurable currency symbols and decimal precision.
Installation
npm install dynamic-currency-formatter
Usage
-React Component: CurrencyInput import { CurrencyInput } from "dynamic-currency-formatter";
function App() { const [price, setPrice] = useState("");
return ( ); }
Utility Functions
-Format a Number to Currency
import { formatCurrencyInput } from "dynamic-currency-formatter";
const formatted = formatCurrencyInput("12345.678", "$"); console.log(formatted); // Outputs: $12,345.67
-Strip Currency Formatting
import { unformatCurrency } from "dynamic-currency-formatter";
const rawValue = unformatCurrency("$12,345.67"); console.log(rawValue); // Outputs: 12345.67