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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@jsfather/persian-ordinal

v1.1.2

Published

Convert numbers from 0 to 999,999,999,999 (999 billion) into Persian ordinal words with ease.

Readme

Persian Ordinal Numbers Converter

This package provides a JavaScript/TypeScript utility function for converting numbers into Persian ordinal words. It supports numbers ranging from 0 to 999,999,999,999 (999 billion) and adheres to the grammatical rules of the Persian language for ordinal numbers. Ideal for applications requiring localized number formatting in Persian.

Key Features

  • Large number support: Converts integers from 0 to 999,999,999,999 (999 billion)
  • TypeScript support: Full TypeScript definitions included
  • Dual module support: Works with both ES modules and CommonJS
  • Persian linguistic accuracy: Handles complex ordinal forms and Persian grammar rules
  • Lightweight and fast: Optimized for performance
  • Zero dependencies: No external dependencies required

Installation

Install the package via npm:

npm install @jsfather/persian-ordinal

Usage

ES Modules (Recommended)

import numberToPersianOrdinal from '@jsfather/persian-ordinal';

console.log(numberToPersianOrdinal(0));           // صفرم
console.log(numberToPersianOrdinal(1));           // یکم
console.log(numberToPersianOrdinal(3));           // سوم
console.log(numberToPersianOrdinal(13));          // سیزدهم
console.log(numberToPersianOrdinal(20));          // بیستم
console.log(numberToPersianOrdinal(123));         // یکصد و بیست و سوم
console.log(numberToPersianOrdinal(1000));        // یک هزارم
console.log(numberToPersianOrdinal(1234567));     // یک میلیون و دویست و سی و چهار هزار و پانصد و شصت و هفتم
console.log(numberToPersianOrdinal(1000000000));  // یک میلیاردم

CommonJS

const numberToPersianOrdinal = require('@jsfather/persian-ordinal');

console.log(numberToPersianOrdinal(673)); // ششصد و هفتاد و سوم

TypeScript

import numberToPersianOrdinal from '@jsfather/persian-ordinal';

const result: string = numberToPersianOrdinal(1234);
console.log(result); // یک هزار و دویست و سی و چهارم

API

numberToPersianOrdinal(number: number): string

Converts an integer into its Persian ordinal word.

  • Parameters:

    • number (number): The number to convert. Must be an integer between 0 and 999,999,999,999.
  • Returns:

    • A string representing the Persian ordinal word.
  • Throws:

    • Error: If the number is not an integer or is out of the supported range.

Examples

| Input | Output | |-------|--------| | 0 | صفرم | | 1 | یکم | | 3 | سوم | | 13 | سیزدهم | | 20 | بیستم | | 123 | یکصد و بیست و سوم | | 1000 | یک هزارم | | 1234 | یک هزار و دویست و سی و چهارم | | 1000000 | یک میلیونم | | 1234567 | یک میلیون و دویست و سی و چهار هزار و پانصد و شصت و هفتم | | 1000000000 | یک میلیاردم |

Error Handling

The function validates input and throws descriptive errors:

try {
    numberToPersianOrdinal(-1);
} catch (error) {
    console.log(error.message); // "Number must be an integer between 0 and 999,999,999,999"
}

try {
    numberToPersianOrdinal(1.5);
} catch (error) {
    console.log(error.message); // "Number must be an integer between 0 and 999,999,999,999"
}

Supported Number Ranges

  • Units: 0-9 → صفرم, یکم, دوم, سوم, چهارم, پنجم, ششم, هفتم, هشتم, نهم
  • Tens: 10-99 → دهم, یازدهم, بیستم, سی‌ام, etc.
  • Hundreds: 100-999 → یکصدم, دویستم, etc.
  • Thousands: 1,000-999,999 → یک هزارم, دو هزارم, etc.
  • Millions: 1,000,000-999,999,999 → یک میلیونم, دو میلیونم, etc.
  • Billions: 1,000,000,000-999,999,999,999 → یک میلیاردم, دو میلیاردم, etc.

Development

# Install dependencies
npm install

# Build the package
npm run build

# Run tests
npm test

# Build TypeScript only
npm run build:tsc

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Changelog

v1.1.0

  • ✅ Added TypeScript support with full type definitions
  • ✅ Extended number support to 999,999,999,999 (999 billion)
  • ✅ Added support for thousands, millions, and billions
  • ✅ Improved module exports (ES modules + CommonJS)
  • ✅ Enhanced error handling and validation
  • ✅ Added comprehensive test coverage

v1.0.3

  • ✅ Basic support for numbers 0-999
  • ✅ Persian ordinal conversion