1.0.3 • Published 6 months ago

monify-ts v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

🌍 Monify - A Simple Currency Formatter

Monify is a lightweight currency formatting library built with TypeScript. It supports multiple currencies and provides flexible formatting options.

📦 Installation

npm install monify-ts

or with yarn:

yarn add monify-ts

🚀 Usage

import { format } from "monify-ts";

📦 Basic Usage

console.log(format(1234567.89, "USD")); // "$1,234,567.89"
console.log(format(1234567.89, "EUR")); // "1.234.567,89 €"
console.log(format(1234567.89, "IDR")); // "Rp 1.234.567,00"

// Custom decimal digits
console.log(format(1234567.89, "JPY", 0)); // "¥1,234,567"

// Disable currency symbol spacing
console.log(format(1234567.89, "GBP", 2, false, false)); // "£1,234,567.89"

// Enable suffix formatting
console.log(format(1500000, "USD", 2, true)); // "$1.5M"

📜 API Reference

format(
  value: number,
  currency: string,
  decimalDigits?: number,  // Optional (Default: Auto)
  useSuffix?: boolean,     // Optional (Default: false) → Enable "K, M, B" suffix
  useSpace?: boolean       // Optional (Default: true) → Add space between symbol and number
): string

🌎 Supported Currencies

CurrencyCodeExample Output
US DollarUSD$1,234,567.89
EuroEUR1.234.567,89 €
Indonesian RupiahIDRRp 1.234.567,00
Japanese YenJPY¥1,234,567
British PoundGBP£1,234,567.89
Australian DollarAUD$1,234,567.89
Canadian DollarCAD$1,234,567.89
Chinese YuanCNY¥1,234,567.89
Indian RupeeINR₹12,34,567.89
South Korean WonKRW₩1,234,567
Swiss FrancCHFCHF 1’234’567.89
Singapore DollarSGD$1,234,567.89
Hong Kong DollarHKDHK$1,234,567.89
Malaysian RinggitMYRRM 1,234,567.89
Philippine PesoPHP₱1,234,567.89
Thai BahtTHB฿1,234,567.89
New Zealand DollarNZD$1,234,567.89
Brazilian RealBRLR$ 1.234.567,89
Russian RubleRUB1 234 567,89 ₽
Mexican PesoMXN$1,234,567.89
South African RandZARR 1,234,567.89
Turkish LiraTRY₺1.234.567,89
Swedish KronaSEK1 234 567,89 kr
Norwegian KroneNOKkr 1 234 567,89
Danish KroneDKK1.234.567,89 kr.
Polish ZlotyPLN1 234 567,89 zł
Hungarian ForintHUF1 234 567,89 Ft
Czech KorunaCZK1 234 567,89 Kč
Argentine PesoARS$ 1.234.567,89
Chilean PesoCLP$1.234.568
Colombian PesoCOP$ 1.234.567,89
Peruvian SolPENS/ 1,234,567.89
Vietnamese DongVND1.234.568 ₫
Pakistani RupeePKR₨ 1,234,567.89
Nigerian NairaNGN₦1,234,567.89
Kenyan ShillingKESKsh 1,234,567.89

🧪 Running Tests

To run tests, use:

npm test

or

yarn test

Tests are written using Jest, covering multiple currencies to ensure accuracy.

🤝 Contributing

Contributions are welcome! To contribute:

Fork the repository.
Clone your forked repo.
Create a new feature branch.
Implement and test changes.
Submit a pull request.

📜 License

Monify is released under the MIT License.

📩 Support

For questions or issues, open a GitHub Issue or contact me at lelianto.eko@gmail.com.

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago