digit-to-words-nepali
Version:
A comprehensive TypeScript library for converting numbers to words in English and Nepali languages. Supports numbers up to 10^39 (Adanta Singhar), currency formatting, decimal handling, and BigInt. Zero dependencies, fully tested.
21 lines (20 loc) • 560 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatWords = formatWords;
exports.padDecimal = padDecimal;
exports.formatCurrencyAmount = formatCurrencyAmount;
function formatWords(words) {
return words
.filter(Boolean)
.join(' ')
.replace(/\s+/g, ' ')
.trim();
}
function padDecimal(decimal) {
return decimal.padStart(2, '0');
}
function formatCurrencyAmount(amount, currency, lang) {
return lang === 'ne'
? `${currency} ${amount}`
: `${amount} ${currency}`;
}