digit-to-words-nepali

A typed npm library for Nepali and English number words, BigInt values, currencies, decimals, and digit transliteration.

By Nirdesh Pokharel · Backend Software Engineer

Read as Markdown

Architecture

number / string / bigint → Input validation → Scale lookup → Language and currency formatting → Words

Problem and interface

Nepali number formatting uses scales such as lakh, crore, arab, and kharab, together with language-specific number words. The library accepts number, numeric string, and bigint inputs and produces Nepali or English output with configurable currency behavior.

Precision boundary

The documented upper bound is 10^41 − 1. BigInt and string inputs preserve integers beyond JavaScript’s safe-integer range; converting an already-rounded JavaScript number cannot recover its original digits. Range and input validation are therefore part of the interface, not merely formatting details.

Decimal and currency handling

The library distinguishes individual decimal-digit pronunciation from combined decimal quantities. Currency output supports configurable currency names and suffixes. Rounding, zero decimals, and explicitly supplied trailing zeros affect output, so callers need predictable formatting rules.

Implementation choices

The README describes LRU caching, reusable converter instances, and binary search over the scale table. These are implementation strategies rather than a published performance benchmark. The package also provides ASCII and Nepali digit-transliteration helpers.

Testing and documentation

The repository includes tests, TypeScript types, usage documentation, and examples around large values and formatting boundaries. Useful regression cases include the maximum supported integer, values just outside the range, zero, invalid inputs, and decimal rounding that carries into the integer part.

Scope

The package is published on npm and has zero external dependencies according to its documentation. It handles number representation; it does not perform currency conversion or establish financial rounding policy for an application.

Source: public project repository →

More engineering notes

Contact

nirdeshpokhrel29@gmail.com