@knownasrazi/ordinal
v1.0.0
Published
Ordinal suffixes (1st, 2nd, 3rd) with locale-aware rules.
Maintainers
Readme
ordinal
Ordinal suffixes (1st, 2nd, 3rd) with locale rules.
Zero dependencies - ~2 KB gzipped - TypeScript - Node + Bun + browser
Install
bun add @knownasrazi/ordinal
npm install @knownasrazi/ordinalUsage
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 lintLicense
ordinal - numbers that rank.
