Skip to content

Repository files navigation

ordinal

Ordinal suffixes (1st, 2nd, 3rd) with locale rules.

npm version npm downloads bundle size license CI

Zero dependencies - ~2 KB gzipped - TypeScript - Node + Bun + browser


Install

bun add @knownasrazi/ordinal
npm install @knownasrazi/ordinal

Usage

import { ordinal, ordinalSuffix } from "@knownasrazi/ordinal";

ordinal(1); // "1st"
ordinal(2); // "2nd"
ordinal(13); // "13th"
ordinal(21); // "21st"
ordinalSuffix(1); // "st"

API

Export Signature
ordinal(n, locale?, compact?) number -> "1st"
ordinalSuffix(n, locale?, compact?) number -> "st"
ordinalWords(n) spell small numbers

locale: "en-US" | "en-GB".

Development

git clone https://github.com/knownasrazi/ordinal.git
cd ordinal
bun install
bun test
bun run build
bun run lint

License

MIT + Razi


ordinal - numbers that rank.

About

Ordinal suffixes (1st, 2nd, 3rd) with locale-aware rules.

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages