1.0.3 • Published 1 year ago

hindi-jokes v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

npm-hindi-jokes

hindi-jokes is a fun Node.js package that delivers a collection of Hindi jokes. Perfect for adding a touch of humor to your applications!`

⚠️ Important: The current version of hindi-jokes supports only ES modules (import/export) syntax. CommonJS (require/module.exports) is not supported. Ensure your environment is configured to handle ES modules.

Features

  • Get a specific Hindi joke by its number.
  • Retrieve a random Hindi joke.
  • Easy to use and integrate into your JavaScript or TypeScript projects.

Installation

To install the hindi-jokes package, run one of the following commands:

npm install hindi-jokes

OR

npm i hindi-jokes

Usage

Importing the Package

import {getCurrentJoke, getRandomJoke} from 'hindi-jokes'

Example Code

import { getCurrentJoke, getRandomJoke } from 'hindi-jokes';

async function fetchJoke(jokeNo) {
    try {
        const joke = await getCurrentJoke(jokeNo);
        console.log('Joke:', joke);
    } catch (error) {
        console.error('Error fetching the joke:', error);
    }
}

async function fetchRandomJoke() {
    try {
        const joke = await getRandomJoke();
        console.log('Random Joke:', joke);
    } catch (error) {
        console.error('Error fetching a random joke:', error);
    }
}

// Fetch a specific joke
fetchJoke(5);

// Fetch a random joke
fetchRandomJoke(); 

API Reference

1. getCurrentJoke(jokeNo: number): Promise<string>

Fetches the Hindi joke with the specified number.

Parameters:

  • jokeNo (number): The number of the joke you want to retrieve.

Returns:

  • A Promise that resolves to a string containing the joke.

Example:

const joke = await getCurrentJoke(1);
console.log(joke); // Output: "वो अपनी पतली कमर पर साड़ी बांध रही थी ऐसे सिविल इंजीनियर     नदी पर पुल बांध रहा हो जैसे 😆🤣😋😉" 

2. getRandomJoke(): Promise<string>

Fetches a random Hindi joke.

Parameters:

  • It does not take any parameter

Returns:

  • A Promise that resolves to a string containing the joke.

Example:

const joke = await getRandomJoke();
console.log(joke); // Output: "वो अपनी पतली कमर पर साड़ी बांध रही थी ऐसे सिविल इंजीनियर     नदी पर पुल बांध रहा हो जैसे 😆🤣😋😉" 
1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago