SCRAMB

a useful package for some random functions related to javascript with few lines and types.

Current Version: v3.0.6 β”€β”€ Latest Update: Apr 24, 2022

Comparison

Example Password Generator.

Without Scramb
const string = "ABCDEFGHIJKLMNOPQRSTUVFXYZabcdefghijklmnopqrstuvwxyz1234567890"
function makeId(number) {
    if(isNaN(number) == true) {
        throw new Error('Input a number of length id!')
    }
    let result = '';
    const charlength = string.length;
    for(let i = 0; i < number; i++) {
        result += string.charAt(Math.floor(Math.random() * charlength));
    }
    const final = {
        result: result
    }
    return final;
}
With Scramb
const scramb = require('scramb')
const pass = scramb.passGen(8) // 8 is length of password (you can change this)
console.log(pass) // json result (pass.result for plain text result)

With Scramb But HTML
document.getElementById('blabla').innerHTML = passGen(8).result


Instalation

From NPM:

npm i scramb

CDN:

<script src="https://jastinxyz.github.io/scramb/cdn/v3.0.4/scramb.js"></script>

Or Minified CDN:

<script src="https://jastinxyz.github.io/scramb/cdn/v3.0.4/scramb.min.js"></script>

Functions

True False

Boolean

<scramb>.boolean()

Yes No

Random Yes or No

<scramb>.yesNo()

Option

Random between 2 input options.

<scramb>.option('option1', 'option2')

Random Array

The result is the contents of one of the arrays.

const array = // ... something array
<scramb>.randomArr(array)

Make ID

Making ID.

const number = // number for id length
<scramb>.makeId(number)

Password Generator

Random Password.

const number = // number for id length
<scramb>.passGen(number)

Random String

Making ID.

<scramb>.randomString('STRING', 'NUMBER OF LENGTH')

String Checker

is String?

<scramb>.isString(SOME VALUE)

Is Number

is Number?

<scramb>.isNumber(SOME VALUE)

Min Max

The result is a random number between <min> and <max>

<scramb>.minMax("min number", "max number")

Random User Agent

Generate random user agent

<scramb>.userAgents()

Email Checker

is Email?

<scramb>.isEmail("STRING")

URL Checker

is URL?

<scramb>.isURL("STRING")

Rock Paper Scissors

rps

<scramb>.rps()

Make Number Id

like the makeId function but here only numbers.

<scramb>.makeidNumber("LENGTH")

Magic Conch Shell

I don't know why made this function but it looks interesting. Inspired by the Spongebob cartoon.

<scramb>.magicConchShell() // results will be random between "Maybe someday.", "Nothing.", "Neither.", "I don't think so.", "No.", "Yes.", "Try asking again.", "Nooo!"

Shuffle

shuffle the given array.

const arr = //array
<scramb>.shuffle(arr)

Coin Flip

Flip a coin!

<scramb>.coin() // results will be random between heads and tails

Falsy

Generate falsy values ​​in javascript randomly.

<scramb>.falsy()

Youtube url checker

is youtube url?

<scramb>.isYoutubeURL("url")

Instagram url checker

is instagram url?

<scramb>.isInstagramURL("url")

Soundcloud url checker

is soundcloud url?

<scramb>.isSoundcloudURL("url")

Changelog

v3.0.6 - From contributor (ThisMe124)

  • [+] <scramb>.isYoutubeURL()
  • [+] <scramb>.isInstagramURL()
  • [+] <scramb>.isSoundcloudURL()

v3.0.4

  • [+] <scramb>.makeidNumber("length") - From contributor (ThisMe124)
  • [+] <scramb>.magicConchShell()
  • [+] <scramb>.shuffle(["array"])
  • [+] <scramb>.coin()
  • [+] <scramb>.falsy()
  • [/] Fixed the comparison in the docs...

v3.0.0

  • [/] Changed .trueOrFalse() to .boolean()
  • [+] Docs At https://jastinxyz.github.io/scramb/
  • [+] <scramb>.userAgents()
  • [+] <scramb>.isEmail("STRING")
  • [+] <scramb>.isURL("STRING")
  • [+] <scramb>.rps()

v2.0.5

  • [+] <scramb>.isNumber()
  • [+] <scramb>.isString()
  • [+] <scramb>.minMax()

v2.0.0

  • First stable release

Contributors




Made With and by JastinLT.