![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@qit.tools/ordinal-format
Advanced tools
This tiny library (🪶 726 bytes) given number into its ordinal representation based on the specified locale and custom suffixes. Ordinal numbers denote position or order (e.g., 1st, 2nd, 3rd).
This library provides a simple utility to format numbers as ordinal strings, supporting different locales and custom suffixes based on Intl.PluralRules().
npm i @qit.tools/ordinal-format
pnpm add @qit.tools/ordinal-format
yarn add @qit.tools/ordinal-format
import { OrdinalFormat } from "@qit.tools/ordinal-format";
const ordinal = new OrdinalFormat();
console.log(ordinal.format(1)); // '1st'
console.log(ordinal.format(2)); // '2nd'
console.log(ordinal.format(3)); // '3rd'
const frSuffixes = [
["one", "er"],
["other", "e"]
];
const ordinal = new OrdinalFormat({ locale: "fr-FR", suffixes: frSuffixes });
console.log(ordinal.format(1)); // '1er'
console.log(ordinal.format(2)); // '2e'
console.log(ordinal.format(3)); // '3e'
const pluralSuffixes = [
["one", " cat"],
["other", " cats"]
];
const ordinal = new OrdinalFormat({ locale: "en-US", suffixes: pluralSuffixes });
console.log(ordinal.format(1)); // '1 car'
console.log(ordinal.format(2)); // '2 cats'
console.log(ordinal.format(3)); // '3 cats'
OrdinalFormat
A class to format numbers as ordinal strings.
constructor(options?: Options)
options
(Options, optional): An optional object to specify the locale and custom suffixes.formatOrdinal
Formats a number as an ordinal string.
formatOrdinal(num: number): string
num
(number): The number to be formatted as an ordinal.type Options = {
locale?: string;
suffixes?: [string, string][];
};
locale
(optional): The locale code (e.g., "en-US", "fr-FR") that determines the language rules for ordinal formatting. Defaults to "en-US".suffixes
(optional): An array of tuples, where each tuple consists of a plural rule category (e.g., "one", "two", "few", "other") and its corresponding ordinal suffix.MIT
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Developed by Qit.tools.
Feel free to explore the source code and contribute to this library on GitHub.
FAQs
This tiny library (🪶 726 bytes) given number into its ordinal representation based on the specified locale and custom suffixes. Ordinal numbers denote position or order (e.g., 1st, 2nd, 3rd).
The npm package @qit.tools/ordinal-format receives a total of 0 weekly downloads. As such, @qit.tools/ordinal-format popularity was classified as not popular.
We found that @qit.tools/ordinal-format demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.