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 🙏

© 2025 – Pkg Stats / Ryan Hefner

bee-jokes

v1.1.0

Published

bee-jokes is a lightweight TypeScript/JavaScript package that delivers clean, categorized, and multilingual jokes — fast and ready to sting your apps with humor!

Downloads

36

Readme

Logo

MIT License

bee-jokes

bee-jokes is a lightweight TypeScript/JavaScript package that delivers clean, categorized, and multilingual jokes — fast and ready to sting your apps with humor! Fetch jokes by ID, tag, category, or at random and keep your projects buzzing with laughter.

⬇️ Installation

Install bee-jokes with npm

md my-project
cd my-project
npm install bee-jokes

💿 Usage/Examples

import { Joke } from 'bee-jokes';
// const {Joke} = require("bee-jokes")

const joke = new Joke();
const my_joke = joke.getJoke({});
console.log(my_joke);

/* Output
{
    "id": "travel-001",
    "joke": "I used to be a travel agent, but I gave it up. It was just too much baggage.",
    "category": "travel",
    "langCode": "en",
    "tags": ["agent", "luggage", "pun"]
} */

🧰 All functions

Usage and paramter list of all avilable functions

getJokeById()

Retrieves a joke by its unique ID.

import { Joke } from 'bee-jokes';

const joke = new Joke();
const my_joke = joke.getJokeById('programming-001');
console.log(my_joke);

/* Output
  {
    "id": "programming-001",
    "joke": "Why do programmers prefer dark mode? Because light attracts bugs.",
    "category": "programming",
    "langCode": "en",
    "tags": ["bugs", "dark-mode", "developer"]
  } */

| Parameter | Type | required | Description | | --------- | -------- | -------- | ------------------------------- | | id | string | True | The ID of the joke to retrieve. |

Returns: IJoke | null — The matching joke object if found, otherwise null.

getAllJokes()

Retrieves all jokes.

import { Joke } from 'bee-jokes';

const joke = new Joke();
const all_jokes = joke.getAllJokes();
console.log(all_jokes);

/* Output
[
      {
    "id": "programming-001",
    "joke": "Why do programmers prefer dark mode? Because light attracts bugs.",
    "category": "programming",
    "langCode": "en",
    "tags": ["bugs", "dark-mode", "developer"]
  },
  {
    "id": "travel-001",
    "joke": "I used to be a travel agent, but I gave it up. It was just too much baggage.",
    "category": "travel",
    "langCode": "en",
    "tags": ["agent", "luggage", "pun"]
  }
...
] */

| Parameter | Type | required | Description | | --------- | ---- | -------- | ---------------------------------- | | - | - | - | This function takes no parameters. |

Returns: IJoke[] | null — The matching joke object if found, otherwise null.

getJoke()

Retrieves a single joke based on the specified category and language.

import { Joke } from 'bee-jokes';

const joke = new Joke();
const my_joke = joke.getJoke({ category: 'programming', lang: 'en' });
console.log(my_joke);

/* Output
  {
    "id": "programming-001",
    "joke": "Why do programmers prefer dark mode? Because light attracts bugs.",
    "category": "programming",
    "langCode": "en",
    "tags": ["bugs", "dark-mode", "developer"]
  } */

| Parameter | Type | required | Description | | ---------- | -------- | -------- | ------------------------------------------------------------------------- | | category | string | False | The category of the joke (defaults to a random category if not provided). | | lang | string | False | The language code for the joke (defaults to "en" if not provided). |

Returns: IJoke | null — The matching joke object if found, otherwise null.

getManyJokes()

Retrieves multiple jokes based on the specified category, language, and range.

import { Joke } from 'bee-jokes';

const joke = new Joke();
const jokes = joke.getManyJokes({ category: 'programming', lang: 'en', range: 5 });
console.log(jokes);

/* Output
[
      {
    "id": "programming-001",
    "joke": "Why do programmers prefer dark mode? Because light attracts bugs.",
    "category": "programming",
    "langCode": "en",
    "tags": ["bugs", "dark-mode", "developer"]
  },
  {
    "id": "programming-002",
    "joke": "Why do programmers always mix up Halloween and Christmas? Because Oct 31 == Dec 25!",
    "category": "programming",
    "langCode": "en",
    "tags": ["dates", "binary", "developer"]
  },
...
] */

| Parameter | Type | required | Description | | ---------- | -------- | -------- | ------------------------------------------------------------------------- | | category | string | False | The category of the joke (defaults to a random category if not provided). | | lang | string | False | The language code for the joke (defaults to "en" if not provided). | | range | number | False | The maximum number of jokes to return (defaults to 10) |

Returns: IJoke[] | null — The matching joke object if found, otherwise null.

getJokeByKeyword()

Retrieves jokes that contain at least one of the specified keyword tags.

import { Joke } from 'bee-jokes';

const joke = new Joke();
const jokes = joke.getJokeByKeyword(['bugs', 'developer'], 5);
console.log(jokes);

/* Output
  [  
      {
    "id": "programming-001",
    "joke": "Why do programmers prefer dark mode? Because light attracts bugs.",
    "category": "programming",
    "langCode": "en",
    "tags": ["bugs", "dark-mode", "developer"]
  },
  ...
]
   */

| Parameter | Type | required | Description | | --------- | -------- | -------- | ------------------------------------------------------ | | tags | array | true | An array of keyword tags to match against joke tags. | | range | number | False | The maximum number of jokes to return (defaults to 10) |

getRandomJoke()

Retrieves a random joke in the specified language.

import { Joke } from 'bee-jokes';

const joke = new Joke();
const randomJoke = joke.getRandomJoke('en');
console.log(randomJoke);

/* Output
  {
    "id": "programming-002",
    "joke": "Why do programmers always mix up Halloween and Christmas? Because Oct 31 == Dec 25!",
    "category": "programming",
    "langCode": "en",
    "tags": ["dates", "binary", "developer"]
    }
*/

| Parameter | Type | required | Description | | --------- | -------- | -------- | ------------------------------------------------------------------ | | lang | string | False | The language code for the joke (defaults to "en" if not provided). |

Returns: IJoke | null — The matching joke object if found, otherwise null.

getSafeJokes()

Retrieves a list of safe jokes based on the specified category, language, and range.
Safe jokes are filtered using the filterSafeJokes utility.

import { Joke } from 'bee-jokes';

const joke = new Joke();
const safeJokes = joke.getSafeJokes({ category: 'programming', lang: 'en', range: 5 });
console.log(safeJokes);

/* Output
  {
    "id": "programming-002",
    "joke": "Why do programmers always mix up Halloween and Christmas? Because Oct 31 == Dec 25!",
    "category": "programming",
    "langCode": "en",
    "tags": ["dates", "binary", "developer"]
    }
*/

| Parameter | Type | required | Description | | ---------- | -------- | -------- | ------------------------------------------------------------------------- | | category | string | False | The category of the joke (defaults to a random category if not provided). | | lang | string | False | The language code for the joke (defaults to "en" if not provided). | | range | number | False | The maximum number of jokes to return (defaults to 10) |

Returns: IJoke[] | null — The matching joke object if found, otherwise null.

getLanguages()

Retrieves the list of supported languages.

import { Joke } from 'bee-jokes';

const joke = new Joke();
const languages = joke.getLanguages();
console.log(languages);

/* Output
  [
  {
    "name": "programming",
    "description": "Jokes for developers, coders, and software engineers."
  },
  {
    "name": "general",
    "description": "Light-hearted and everyday jokes for everyone."
  },
  {
    "name": "dadjokes",
    "description": "Classic groan-worthy dad jokes and puns."
  },
  ...
  ]
*/

| Parameter | Type | required | Description | | --------- | ---- | -------- | ---------------------------------- | | - | - | - | This function takes no parameters. |

Returns: ILanguage[] | null — An array of language objects, each containing a language code and its corresponding name..

getCategories()

Retrieves the list of available joke categories.

import { Joke } from 'bee-jokes';

const joke = new Joke();
const categories = joke.getCategories();
console.log(categories);

/* Output
  [
  { "code": "en", "language": "English" },
  { "code": "hi", "language": "Hindi" },
  { "code": "es", "language": "Spanish" },
  ...
  ]
*/

| Parameter | Type | required | Description | | --------- | ---- | -------- | ---------------------------------- | | - | - | - | This function takes no parameters. |

Returns: ICategory[] | null — An array of category objects, each containing the category name..

🤝 Contribution

Contributions are welcome and appreciated! If you have suggestions for improvements, feel free to open an issue or submit a pull request. Let’s make bee-jokes better together! 🐝✨

🚀 Run Locally

Clone the project

git clone https://github.com/sandeep-shome/bee-jokes.git

Go to the project directory

cd my-project

🔧 Install dependencies

npm install

You can now explore and modify the package as per your needs.

📦 Build the Project

npm run build

🧪 Running Tests

To run tests, run the following command

npm run test

🧩 Features

  • Minimal setup
  • New Jokes every month
  • Open source
  • Accepting contributions

🧱 Tech Stack

Node, Typescript, Tsup, Eslint, Husky, Prettier

📎Appendix

bee-jokes is an open-source project developed and maintained by a solo developer with a passion for clean code, creativity, and community-driven tools.

You're welcome to explore, use, and contribute to the project! Whether it's fixing a bug, suggesting a feature, or improving the documentation — your contributions are highly appreciated.

Feel free to check out the GitHub repository and join in making this project better for everyone. Let's build something fun together! 💡

🗺️ Roadmap

  • Additional browser support
  • Add more jokes
  • Add more features & filters

👨‍💻 Authors

@Sandeep Shome

📄 License

MIT

🔗 Related

Here are some related projects

pyjokes

🙋‍♂️ Support

For support, email [email protected]