number-to-text-converter v1.0.2
Number to Words
A lightweight npm package to convert numbers into their text representation (e.g., 1000
→ "one thousand"
).
Installation
You can install the package via npm:
npm i number-to-text-converter
or
yarn add number-to-text-converter
Basic Usage
const numberToWords = require('number-to-text-converter');
console.log(numberToWords(1000)); // "one thousand"
console.log(numberToWords(1010)); // "one thousand ten"
console.log(numberToWords(123456)); // "one hundred twenty-three thousand four hundred fifty-six"
console.log(numberToWords(999999999)); // "nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine"
Edge Cases
console.log(numberToWords(0)); // "zero"
console.log(numberToWords(-42)); // "negative forty-two"
console.log(numberToWords(1000000)); // "one million"
API
numberToWords(number) - number (Number): The number to convert into words. - Returns (String): The text representation of the number.
Supported Range
This package supports numbers in the range of -999,999,999,999,999 to 999,999,999,999,999 (quadrillions).
Contributing
Contributions are welcome! If you find a bug or want to add a feature, please open an issue or submit a pull request.
Fork the repository.
Create a new branch (git checkout -b feature/your-feature).
Commit your changes (git commit -m 'Add some feature').
Push to the branch (git push origin feature/your-feature).
Open a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
If you find this package useful, please consider giving it a ⭐️ on GitHub!