Only this pageAll pages
Powered by GitBook
1 of 11

Insiders

Loading...

Examples

Loading...

Loading...

Documentation

Loading...

Loading...

Loading...

Loading...

Misc

Loading...

Random Joke

An example of how to generate a random joke!

Code

// This snippet uses some-random-cat version 2.0

const somethingRandom = require('some-random-cat').Random
somethingRandom.getJoke()
.then(res => {
    console.log(res)
    return
}) // Get the result
.catch(e => {
    console.error(e)
    return
}) // Catch the error

Output

Introduction

Hi there, this is the insider build documentation that has new features documented! See the dev branch in GitHub for the same.

Installation

To install the package, you would have to make sure that node.js is installed on your machine. After that, you can simply do npm i some-random-cat in the terminal where you want to install the package or npm i some-random-cat -g to install it globally.

About

I saw that there were not many good packages for generating random stuff. So I decided to make one. A very suitable API to generate random images of cats, dogs and random jokes, facts... A lot more!

Why?

  • Object-oriented

  • Speedy and efficient

  • Feature-rich

  • Easy

  • Beginner-Friendly

  • Flexible

Example

Generate a random cat image:

const somethingRandom = require('some-random-cat').Random //Import the package
somethingRandom.getCat()
.then(res => {
    console.log(res)
    return
}) // Get the result
.catch(e => {
    console.error(e)
    return
}) // Catch the error

Statistics

  • 600+ downloads

Written in JavaScript Edited in Visual Studio Code

Random

Random Cat Image

An example of how to generate a random cat image!

Code

// This snippet uses some-random-cat version 2.0

const somethingRandom = require('some-random-cat').Random
somethingRandom.getCat()
.then(res => {
    console.log(res)
    return
}) // Get the result
.catch(e => {
    console.error(e)
    return
}) // Catch the error

Output

Generation

The class for generating secure IDs, formatting time and much more...

Please make sure you do not instantiate this class. You can access it throughconst somethingRandom = require('some-random-cat').Generation

Generation method to format time to 00:00

Generation method to secure a well secure UUID.

Generation method to get acronym for a string.

Generation method to shorten a string by length.

Methods

.formatTime(time) STATIC

Returns: <>

.generateId(options) STATIC

Returns: <>

.getAcronym(name) STATIC

Returns: <>

.shorten(text, length) STATIC

Returns: <>

PARAMETER

TYPE

OPTIONAL

DEFAULT

DESCRIPTION

name

String

❌

none

The string to get acronym for.

PARAMETER

TYPE

OPTIONAL

DEFAULT

DESCRIPTION

text

String

❌

none

The string to shorten.

length

Number

❌

none

The length to shorten.

</ >
</ >
Promise
String
</ >
Promise
String
</ >
Promise
String
</ >
Promise
String

PARAMETER

TYPE

OPTIONAL

DEFAULT

DESCRIPTION

time

❌

none

The time to format.

PARAMETER

TYPE

OPTIONAL

DEFAULT

DESCRIPTION

options

✅

none

The options for the ID.

options.putDash

✅

true

Whether or not to put a -

Classes

All the classes available for the current version.

Available Classes

  • Random - The random class includes all random things from advice to topic.

  • Util - The pacakge basic info and testing.

Go to

Number
Object
Boolean
Random
Util

Random

The class for generating random things such as cat images, dog images, jokes and much more!

Please make sure you do not instantiate this class. You can access it though const something = require('some-random-cat').Random

Random method to generate an advice.

Type

Description

any

The string with the advice.

Random method to generate a random cat image.

Type

Description

any

URL for the image.

Random method to generate a random dog image.

Type

Description

any

URL for the image.

Random method to generate a random fact.

Type

Description

any

The string for the fact.

Random method to generate a random joke.

Type

Description

any

An object with the title, description and URL

Random method to generate a meme.

Parameters

Type

Optional

Description

sub

String

❌

The subreddit to get the meme from.

Gets a random string of a length.

Parameters

Type

Optional

Description

number

Number

❌

The length of the string.

Random method to generate a topic.

Type

Description

any

The string with the topic.

Methods

.getAdvice() STATIC

Returns:

.getCat() STATIC

Returns:

.getDog() STATIC

Returns:

.getFact() STATIC

Returns:

.getJoke() STATIC

Returns:

.getMeme(sub) STATIC

Returns:

.getString(number) STATIC

Returns:

.getTopic() STATIC

Returns:

</ >
</ >
Promise<Pending>
</ >
Promise<Pending>
</ >
Promise<Pending>
</ >
Promise<Pending>
</ >
Promise<Pending>
</ >
Promise<Pending>
</ >
Promise<Pending>
</ >
Promise<Pending>

Reading Notation

Gives basic information on how to read the classes and stuff.

Throughout the whole SomeRandomCat documentation or in the support server, you may see notation very often. To help you understand those, we will be going over a few common types of them.

Always keep in mind that notation is not always rigorous. There will be typos, misunderstandings, or context that will cause notation to differ from the usual meanings.

Classes

Some common notations are used to refer to a class or the properties, methods, or events of a class. There are many variations on these notations, and they are very flexible depending on the person, so use your best judgement when reading them. For example, if you are given a text <Random>, it means an instance of the class Random. It is telling you to replace it with your own instance that you have made, but in our case, it is STATIC which means there is no hustle and bustle of instantiating it.

The notation Class#foo refers to a property called foo in the class Class. However in the case of STATIC properties you write it as Class.foo

To write an event, you can write it as <Class>#<property>:<event>

Remember that this notation is not valid JavaScript, it is a shorthand to refer to a certain piece of code.

Util

The class for getting information on the package or testing it.

Please make sure you do not instantiate this class. You can access it though const something = require('some-random-cat').Util

Properties

.info STATIC

The general information for the package.

PARAMETER

TYPE

DESCRIPTION

author

String

The author(s) of the package.

description

String

The description of the package.

repo

Object

Current repository(s) of the package.

version

String

The version of the package.

Methods

.test() STATIC

Random method to generate an advice.

Type

Description

any

Tests the package and retrieves an error(if any).

Examples:

const somethingRandom = require('some-random-cat').Util
somethingRandom.test()
NPM
Discord

Type: ?

Returns:

Object
Promise<Pending>
npm
Total Downloads
Note: This returns a default JavaScript Object.
GitHub Repo stars
NPM