ngx-number-converter-indian
v1.0.63
Published
A library for converting numbers to words in Indian and International formats (works in Angular, React, and Node.js)
Maintainers
Keywords
Readme
ngx-number-converter-indian
A library for converting numbers to words in Indian and International formats (works in Angular, React, and Node.js)
Features
- Convert numbers to words in English (Indian and International formats)
- Convert numbers to words in Hindi (Indian format)
- Supports both positive and negative numbers
- Proper handling of zero values
Installation
npm install ngx-number-converter-indianUsage
In Angular Projects
- Use the service in your components:
import { NumberConverter } from 'ngx-number-converter-indian';
export class YourComponent {
convertNumber() {
// IMPORTANT: Only use the static method NumberConverter.convert()
// Do NOT create an instance of NumberConverter
// Convert number to English words (Indian format)
const englishIndian = NumberConverter.convert(123456789, {
language: 'en',
region: 'india'
});
// Convert number to English words (International format)
const englishInternational = NumberConverter.convert(123456789, {
language: 'en',
region: 'international'
});
// Convert number to Hindi words
const hindi = NumberConverter.convert(123456789, {
language: 'hi',
region: 'india'
});
}
}In React Projects
- Install the library:
npm install ngx-number-converter-indian- Use in your React components:
import { NumberConverter } from 'ngx-number-converter-indian';
// IMPORTANT: Only use the static method NumberConverter.convert()
// Do NOT create an instance of NumberConverter
// Using static method
const result = NumberConverter.convert(123456789, {
language: 'en',
region: 'india'
});
// Example in a React component
function NumberDisplay({ amount }) {
return (
<div>
<p>Indian Format: {converter.convert(amount, { language: 'en', region: 'india' })}</p>
<p>International Format: {NumberConverter.convert(amount, { language: 'en', region: 'international' })}</p>
<p>Hindi: {NumberConverter.convert(amount, { language: 'hi', region: 'india' })}</p>
</div>
);
}In Node.js Applications
const { NumberConverter } = require('ngx-number-converter-indian');
// Option 1: Using instance
const converter = new NumberConverter();
const result = converter.convert(123456789, {
language: 'en',
region: 'india'
});
// Option 2: Using static method
const result = NumberConverter.convert(123456789, {
language: 'en',
region: 'india'
});
console.log(result); // "One Crore Twenty Three Lakh Forty Five Thousand Six Hundred Seventy Eight"Interface
interface LanguageOptions {
language: 'en' | 'hi';
region: 'india' | 'international';
}Supported Formats
- English (Indian): "One Crore Twenty Three Lakh Forty Five Thousand Six Hundred Seventy Eight"
- English (International): "One Hundred Twenty Three Million Four Hundred Fifty Six Thousand Seven Hundred Eighty Nine"
- Hindi (Indian): "एक करोड़ तीन लाख पैंसठ हजार छह सौ अठानवे"
License
MIT
Author
Developed by Amit Katiyar aka Amit Bharat
