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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ordinalify

v0.8.3

Published

A react component for getting ordinal numbers

Downloads

120

Readme

Ordinalify

npm version

license

Ordinalify is a package used to get number ordinals in javascript apps.

Ordinals: are grammatical or numerical indicators that express the position or order of items in a series, such as "1st" for first, "2nd" for second, and so on.

Installation

Install the package using npm:

npm install ordinalify

Install the package using yarn:

yarn add ordinalify

Usage

Here's a basic example of how to use ordinalify:

Word Ordinals e.g("First", "Second", "Third", "Fourth"):

import { WordOrdinal } from "ordinalify";

const numberRange = Array.from({ length: 4 }, (_, index) => index + 1);

numberRange.map((number) =>
	console.log(WordOrdinal(number, { capitalizeFirstLetter: true }))
);

Number Ordinals e.g ("1ST", "2ND", "3RD", "4TH"):

import { NumberOrdinal } from "ordinalify";

const numberRange = Array.from({ length: 4 }, (_, index) => index + 1);

numberRange.map((number) =>
	console.log(NumberOrdinal(number, { capitalize: true }))
);

API (Parameters)

WordOrdinal

The WordOrdinal function/component is responsible for converting numbers into their ordinal form in word form e.g "Fifth", "Twenty-Nine".

Props:

  • number (required): The number to be converted into an ordinal form.
  • options (optional): An object containing the following properties:
    • capitalizeFirstLetter (optional): A boolean indicating whether the result should be in title case format. This can be used as the second parameter using node or the second prop with the name options and the key value name "capitalizeFirstLetter"

Example: Word Ordinal("first", "second", "third")

In Node:

const { WordOrdinal } = require("ordinalify");

const numberRange = Array.from({ length: 3 }, (_, index) => index + 1);
numberRange.map((number) => console.log(WordOrdinal(number)));

In React:

import React from "react";
import { WordOrdinal } from "ordinalify/dist/react";

const App = () => {
	const numberRange = Array.from({ length: 3 }, (_, index) => index + 1);
	return (
		<section>
			{numberRange.map((number, index) => (
				<WordOrdinal
					key={index}
					number={number}
					options={{ capitalizeFirstLetter: true }}
				/>
			))}
		</section>
	);
};

export default App;

NumberOrdinal

The NumberOrdinal function/component is responsible for converting numbers into their ordinal form in number form e.g "5TH", "29TH".

Props:

  • number (required): The number to be converted into an ordinal form.
  • options (optional): An object containing the following properties:
    • capitalize (optional): A boolean indicating whether the result should be in title case format. This can be used as the second parameter using node or the second prop with the name options and the key value name "capitalizeFirstLetter"
    • lowercase (optional): A boolean indicating whether the result should be in lowercase format.
    • subscript (optional): A boolean indicating whether the result should be in subscript format. (Note: Subscript does not work in Node environment)
    • superscript (optional): A boolean indicating whether the result should be in superscript format. (Note: Superscript does not work in Node environment)

Example: Number Ordinal ("1ST", "2ND", "3RD")

In Node

const { NumberOrdinal } = require("ordinalify");

const numberRange = Array.from({ length: 3 }, (_, index) => index + 1);
numberRange.map((number) =>
	console.log(NumberOrdinal(number, { capitalize: true }))
);

In React

import React from "react";
import { NumberOrdinal } from "ordinalify/dist/react";

const App = () => {
	const numberRange = Array.from({ length: 3 }, (_, index) => index + 1);
	return (
		<section>
			{numberRange.map((number) => (
				<NumberOrdinal
					number={number}
					options={{ capitalize: true }}
				/>
			))}
		</section>
	);
};

export default App;

Contributing

This Markdown document is well-structured and provides clear instructions for using the ordinalify package. If you have any specific concerns or requests, feel free to let me know!