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

@ironarachne/words

v2.0.0

Published

A library for dealing with words

Downloads

407

Readme

@ironarachne/words

A comprehensive TypeScript/JavaScript library for procedural natural language generation, string manipulation, and grammatical inflection. Originally built to provide utility functions for producing natural-sounding English from component parts, it's perfect for text generators, game development, and formatting data seamlessly.

Full documentation is available at words.ironarachne.com/docs.

Installation

npm install @ironarachne/words

Features

The library is organized into specialized domains for all your procedural text needs:

🔤 Casing

Easily change string formats for code, IDs, or display.

  • capitalize, uncapitalize, title (Title Case)
  • camelCase, snakeCase, kebabCase, swapCase

📚 Grammar

Helpers for assembling dynamic sentences to keep your procedural text grammatically correct.

  • Articles & Pronouns: Generate the correct article (a/an) or pronoun based on gender and context.
  • Quantification: quantify(2, "apple") -> "2 apples"
  • Verbs & Copulas: isAre(count), hasHave(count), wasWere(count) to match plurals automatically.
  • Possessives: Properly format nouns (e.g., possessive("James") -> "James'", possessive("dog") -> "dog's").

🔄 Inflection

Robust rules and an expansive irregular dictionary (e.g., radius/radii, goose/geese, deer).

  • pluralize(word: string)
  • singularize(word: string)
  • detectPlural(word: string)

🔢 Numbers

Format numbers as text or traditional numeric formats.

  • getOrdinal(1) -> "1st"
  • ordinalWord(1) -> "first"
  • numberToWords(21) -> "twenty-one"
  • romanize(4) -> "IV"

📝 Text Utilities

Create clean paragraphs, phrases, and text elements.

  • Sentence Building: buildSentence(parts) automatically capitalizes and fixes terminal punctuation.
  • Lists: arrayToPhrase(["apple", "banana"], "or") -> "apple or banana"
  • Punctuation: fixPunctuation(text) fixes double-spaces, space-before-comma, and duplicate punctuation.
  • Formatting: slugify, truncateWords, squish, stripPunctuation
  • Metrics: wordCount, readingTime

Example Usage

Building grammatically accurate procedural sentences is simple:

import { quantify, isAre, arrayToPhrase, buildSentence } from "@ironarachne/words";

const enemyCount = 3;
const enemyType = "goblin";
const loot = ["gold coin", "rusty dagger"];

// "3 goblins"
const enemies = quantify(enemyCount, enemyType); 

// "are"
const copula = isAre(enemyCount); 

// "gold coin and rusty dagger"
const lootPhrase = arrayToPhrase(loot); 

const parts = [
  "there", copula, enemies, "guarding the", lootPhrase
];

// Returns: "There are 3 goblins guarding the gold coin and rusty dagger."
const text = buildSentence(parts); 
console.log(text);

Contributing and Setup

This project uses TypeScript, Vitest for testing, and Biome for formatting.

# Install dependencies
npm install

# Run the test suite
npm run test

# Build the project
npm run build

# Re-generate the TypeDoc documentation
npm run docs

License

MIT License.