Package Exports
- @isahaq/numbertostring
- @isahaq/numbertostring/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@isahaq/numbertostring) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@isahaq/numbertostring
A powerful and flexible multilingual number-to-words converter supporting multiple languages with an easy-to-use API.
✨ Features
- 🌍 Multi-language support: English, Bangla, French, Urdu, Chinese, Hindi, and Spanish
- 🔢 Large number support: Handle numbers from zero to billions
- 💱 Currency formatting: Built-in currency conversion support
- 🎯 TypeScript support: Full type definitions included
- ⚡ Lightweight: Minimal dependencies and small bundle size
- 🛠️ Highly configurable: Customize output format to your needs
📦 Installation
npm install @isahaq/numbertostringOr using yarn:
yarn add @isahaq/numbertostringOr using pnpm:
pnpm add @isahaq/numbertostring🎯 Quick Start
const { numberToWords } = require("@isahaq/numbertostring");
// Basic usage
console.log(numberToWords(123));
// Output: "one hundred twenty-three"
// With language option
console.log(numberToWords(123, { language: "bn" }));
// Output: "একশত তেইশ"
// Currency format
console.log(numberToWords(1234.56, { language: "en", currency: true }));
// Output: "one thousand two hundred thirty-four dollars and fifty-six cents"📖 Usage
Basic Number Conversion
const { numberToWords } = require("@isahaq/numbertostring");
// English (default)
numberToWords(42);
// "forty-two"
// Bangla
numberToWords(42, { language: "bn" });
// "বিয়াল্লিশ"
// French
numberToWords(42, { language: "fr" });
// "quarante-deux"
// Spanish
numberToWords(42, { language: "es" });
// "cuarenta y dos"
// Hindi
numberToWords(42, { language: "hi" });
// "बयालीस"
// Urdu
numberToWords(42, { language: "ur" });
// "بیالیس"
// Chinese
numberToWords(42, { language: "zh" });
// "四十二"Large Numbers
numberToWords(1234567890);
// "one billion two hundred thirty-four million five hundred sixty-seven thousand eight hundred ninety"
numberToWords(1234567890, { language: "bn" });
// "একশত তেইশ কোটি পঁয়তাল্লিশ লক্ষ সাতষট্টি হাজার আটশত নব্বই"Currency Conversion
numberToWords(1234.56, {
language: "en",
currency: true,
currencyUnit: "dollar",
});
// "one thousand two hundred thirty-four dollars and fifty-six cents"
numberToWords(5000, {
language: "bn",
currency: true,
currencyUnit: "taka",
});
// "পাঁচ হাজার টাকা"Custom Options
numberToWords(100, {
language: "en",
titleCase: true,
ordinal: false,
currency: false,
});🌐 Supported Languages
| Language | Code | Example (42) |
|---|---|---|
| English | en |
forty-two |
| Bangla | bn |
বিয়াল্লিশ |
| French | fr |
quarante-deux |
| Spanish | es |
cuarenta y dos |
| Hindi | hi |
बयालीस |
| Urdu | ur |
بیالیس |
| Chinese | zh |
四十二 |
⚙️ API Reference
numberToWords(number, options)
Converts a number to its word representation.
Parameters
number(number): The number to convertoptions(object, optional): Configuration optionslanguage(string): Language code (default:'en')currency(boolean): Format as currency (default:false)currencyUnit(string): Currency unit nametitleCase(boolean): Capitalize first letter (default:false)ordinal(boolean): Convert to ordinal number (default:false)
Returns
- (string): The number converted to words
🤝 Contributing
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
👤 Author
Isahaq
- npm: @isahaq
🙏 Acknowledgments
- Thanks to all contributors who have helped with language translations
- Inspired by similar number-to-words libraries
📊 Support
If you found this project helpful, please give it a ⭐️!
Made with ❤️ by Isahaq