npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

afn-currency-text

v1.0.0

Published

Convert numbers to legal Afghan Afghani (AFN) words in Dari and Pashto. Perfect for invoices, banking, and legal documents. Supports decimals (puls).

Downloads

156

Readme

afn-currency-text

🇦🇫 Convert numbers to legal Afghan Afghani (AFN) wording in Dari and Pashto. Perfect for invoices, banking, and official documents.

npm version license npm downloads CI / Testing

🚀 Why this package?

In Afghan banking, invoicing, and legal documents, it is a strict requirement to write monetary amounts in words (e.g., 15,500 AFN must be written as "پانزده هزار و پانصد افغانی").

While generic number-to-words packages exist, they fail for the Afghan context because:

  1. They default to Iranian Rial/Toman logic.
  2. They don't handle the specific grammar for Afghan Afghani (AFN).
  3. They lack proper support for Pashto translations and conjunctions (like using "او" instead of "و").
  4. They don't correctly format the decimal subunit (Puls / پول).

afn-currency-text is built specifically to solve this, ensuring 100% legal and financial compliance for Afghan documents.

✨ Features

  • 🇦🇫 Tailored for AFN: Specifically designed for Afghan Afghani and its decimal subunit, Puls.
  • 🗣️ Dual Language Support: Native, grammatically correct support for both Dari (da) and Pashto (pa).
  • 🏛️ Legal Compliance: Uses formal legal terminology (e.g., using "هزار" instead of spoken "زر" in Pashto).
  • 🕰️ Legacy Compatible: Written in pure ES3/ES5 syntax. The compiled JavaScript works flawlessly in old environments, including legacy versions of Internet Explorer (IE8+) and older Node.js versions.
  • 📦 Zero Dependencies: Pure TypeScript, resulting in a tiny, lightning-fast bundle.
  • 🛡️ Fully Typed: Ships with built-in TypeScript definitions for excellent IDE autocomplete.

📦 Installation

npm install afn-currency-text
# or
yarn add afn-currency-text

💻 Usage

Basic Usage (Dari)

const { numberToWords } = require('afn-currency-text');
// or import { numberToWords } from 'afn-currency-text';

console.log(numberToWords(15500, 'da'));
// Output: "پانزده هزار و پانصد افغانی"

console.log(numberToWords(1250.75, 'da'));
// Output: "یک هزار و دویست و پنجاه افغانی و هفتاد و پنج پول"

Basic Usage (Pashto)

const { numberToWords } = require('afn-currency-text');

console.log(numberToWords(15500, 'pa'));
// Output: "پنځلس هزار او پنځوسوه افغانۍ"

console.log(numberToWords(2000000, 'pa'));
// Output: "دوه ملیون افغانۍ"

📖 API Reference

numberToWords(amount, lang)

Converts a numerical amount into its legal word representation.

Parameters:

| Name | Type | Description | | :--- | :--- | :--- | | amount | number | The numerical amount to convert (e.g., 15500.50). Must be a positive number. | | lang | 'da' \| 'pa' | The target language code. Use 'da' for Dari and 'pa' for Pashto. |

Returns:

string - The formatted legal string including the currency name and decimals (puls).

Throws:

Error - If the amount is negative or NaN.

🏛️ A Note on Legacy Compatibility

This package is explicitly written using legacy JavaScript syntax (var, standard function declarations, no template literals, no destructuring).

While modern JavaScript is great, many enterprise banking systems, legacy accounting software, and older government portals in the region still run on outdated JavaScript engines. By keeping the source code strictly ES3/ES5 compliant, we guarantee that the compiled output will run anywhere without requiring heavy polyfills or transpilation by the end-user.

🧪 Testing

The package is fully tested using Jest. To run the test suite locally:

npm test

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

📄 License

This project is licensed under the MIT License.