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

@tmllak-erp/formatters

v0.3.0

Published

Number, date, and text formatting for Arabic and English interfaces. Every function returns **Western digits (0–9)** and uses the **Gregorian calendar**, in both languages. Plain `ar-SA` formatting would otherwise switch to Hijri dates and Arabic-Indic di

Downloads

588

Readme

@tmllak-erp/formatters

Number, date, and text formatting for Arabic and English interfaces. Every function returns Western digits (0–9) and uses the Gregorian calendar, in both languages. Plain ar-SA formatting would otherwise switch to Hijri dates and Arabic-Indic digits.

No dependencies, no React, side-effect free. It works in browsers, Node, and server components.

Install

npm install @tmllak-erp/formatters

ESM only, with TypeScript declarations.

Usage

import { formatAmount, formatDate, formatDateTime, formatLongDate, formatNumber, formatPercent, formatRelativeTime } from '@tmllak-erp/formatters';

const date = new Date(2026, 9, 5, 14, 5);

formatNumber(12450.7); // "12,450.7"
formatAmount(12450.7); // "12,450.70" (always two decimals; put the currency in the column header)
formatPercent(0.85); // "85%"
formatDate(date); // "2026/10/05"
formatLongDate(date); // "5 أكتوبر 2026", or "5 October 2026" in English
formatDateTime(date, 'en'); // "5 October 2026 at 14:05"
formatRelativeTime(new Date(Date.now() - 2 * 3_600_000)); // "قبل ساعتين" / "2 hours ago"

| Function | Output | | --- | --- | | formatNumber(value, { minimumFractionDigits?, maximumFractionDigits?, locale? }) | Grouped number, up to 2 decimals by default. | | formatAmount(value, { locale? }) | Number with exactly 2 decimals. | | formatPercent(ratio, fractionDigits?, locale?) | 0.85 → 85% (Western % sign). | | formatDate(date) | YYYY/MM/DD, the same in both languages. | | formatLongDate(date, locale?) | Day, month name, year. | | formatTime(date, locale?), formatDateTime(date, locale?) | Time, or date with time. | | formatMonthYear, formatMonthName, formatWeekday, formatFullDate | Calendar headers and accessible names. | | formatRelativeTime(date, now?, locale?) | "2 hours ago", "in 3 days". | | formatLatinValue(kind, value) | Normalizes phone, email, url, iban, technical-id (see LATIN_VALUE_KINDS). | | toWesternDigits, normalizeNumericInput | Convert Arabic-Indic digits typed by users to 0–9. | | stripBidiControls, toLatinDigits | Clean copied text and digits. |

Language

Functions that take an optional locale ('ar' or 'en') use the active locale when you leave it out. The active locale starts as Arabic. Inside an @tmllak-erp/ui application, ErpProvider sets it for you.

import { formatLongDate, getActiveLocale, setActiveLocale } from '@tmllak-erp/formatters';

setActiveLocale('en');
formatLongDate(new Date(2026, 9, 5)); // "5 October 2026"
getActiveLocale(); // "en"

// An explicit locale always wins, which is the safest choice in server code:
formatLongDate(new Date(2026, 9, 5), 'ar'); // "5 أكتوبر 2026"

| Export | Purpose | | --- | --- | | UI_LOCALES, DEFAULT_UI_LOCALE, isUiLocale | Supported languages (ar, en) and a type guard. Type UiLocale. | | getActiveLocale(), setActiveLocale(locale) | Read or change the active language. | | registerRenderLocaleReader(reader) | For UI layers: report the language of the component rendering on a server (see Servers). | | directionForLocale(locale) | rtl for Arabic, ltr for English. | | intlLocale(locale) | The BCP 47 tag used with Intl (ar-SA-u-nu-latn-ca-gregory, en-GB-u-nu-latn-ca-gregory). |

Servers

On Node.js 20.16+ / 22.3+, and on edge runtimes that provide AsyncLocalStorage, the active locale is kept per request. Concurrent server renders in different languages therefore do not affect each other, including streaming renders that resume after Suspense. Elsewhere it is a single module-level value.

Some renderers resume a suspended part of the page outside the request's async context. Next.js does this when it streams a Suspense boundary from the RSC payload. For that case a UI layer can report the language of the component being rendered with registerRenderLocaleReader. @tmllak-erp/ui registers one that reads ErpProvider (React 19).

Code outside a React render (route handlers, server actions, async server components that await between formatting calls) should pass locale explicitly.

Versions and upgrades

All @tmllak-erp/* packages share one version number. Upgrade them together and read the CHANGELOG.md of each package. While the version is 0.x, a minor release can contain breaking changes.