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

word-jokes

v1.0.0

Published

A fun npm package that generates random jokes starting with a given word. Perfect for adding humor to your applications!

Readme

Word Jokes Package

A fun and simple npm package that generates random jokes starting with a given word. Perfect for adding humor to your applications!

Installation

npm install word-jokes

Usage

Basic Usage

const { getJoke, getRandomJoke, getCategories } = require("word-jokes");

// Get a joke starting with a specific word
console.log(getJoke("what"));
// Output: "What do you call a bear with no teeth? A gummy bear!"

// Get a random joke from any category
console.log(getRandomJoke());
// Output: Random joke from any category

// Get all available categories
console.log(getCategories());
// Output: ["what", "why", "how", "when", "where", "who", "which", "can", "do", "are", "is", "the", "a", "an"]

Advanced Usage

const { getJokesByCategory, jokes } = require("word-jokes");

// Get all jokes from a specific category
const whyJokes = getJokesByCategory("why");
console.log(whyJokes);
// Output: Array of all "why" jokes

// Access the jokes object directly
console.log(jokes.what);
// Output: Array of all "what" jokes

Available Categories

The package includes jokes starting with these words:

  • what - What do you call... jokes
  • why - Why don't... jokes
  • how - How do you... jokes
  • when - When is... jokes
  • where - Where do you... jokes
  • who - Who is... jokes
  • which - Which... jokes
  • can - Can... jokes
  • do - Do you know... jokes
  • are - Are you... pickup lines
  • is - Is your name... pickup lines
  • the - The best time... jokes
  • a - A... walks into a bar jokes
  • an - An... jokes

API Reference

getJoke(word)

Generates a random joke starting with the given word.

Parameters:

  • word (string): The word to start the joke with

Returns:

  • string: A random joke starting with the word, or a default joke if no match found

Example:

getJoke("what"); // Returns a random "what" joke
getJoke("why"); // Returns a random "why" joke

getRandomJoke()

Gets a random joke from any category.

Returns:

  • string: A random joke from any available category

getCategories()

Gets all available joke categories.

Returns:

  • string[]: Array of available joke categories

getJokesByCategory(category)

Gets all jokes from a specific category.

Parameters:

  • category (string): The category to get jokes from

Returns:

  • string[]: Array of jokes from the category, or empty array if category doesn't exist

jokes

The raw jokes object containing all jokes organized by category.

Examples

Node.js Application

const { getJoke } = require("word-jokes");

// Simple joke generator
function tellJoke(word) {
  const joke = getJoke(word);
  console.log(`Here's a joke starting with "${word}":`);
  console.log(joke);
}

tellJoke("how");
tellJoke("why");

Web Application

const { getJoke, getCategories } = require("word-jokes");

// Express.js example
app.get("/joke/:word", (req, res) => {
  const word = req.params.word;
  const joke = getJoke(word);
  res.json({ word, joke });
});

app.get("/categories", (req, res) => {
  const categories = getCategories();
  res.json({ categories });
});

Discord Bot

const { getJoke } = require("word-jokes");

client.on("message", (message) => {
  if (message.content.startsWith("!joke")) {
    const word = message.content.split(" ")[1] || "random";
    const joke = word === "random" ? getRandomJoke() : getJoke(word);
    message.channel.send(joke);
  }
});

Contributing

Feel free to contribute by adding more jokes or improving the existing ones! Just make sure they're family-friendly and appropriate for all audiences.

License

ISC

Author

Vaibhav Sharma


Note: This package is designed to be fun and family-friendly. All jokes are clean and suitable for all audiences.