a useful package for some random functions related to javascript with few lines and types.
Current Version: v3.0.6 ββ Latest Update: Apr 24, 2022Example Password Generator.
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;
}
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)
document.getElementById('blabla').innerHTML = passGen(8).result
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>
Boolean
<scramb>.boolean()
Random Yes or No
<scramb>.yesNo()
Random between 2 input options.
<scramb>.option('option1', 'option2')
The result is the contents of one of the arrays.
const array = // ... something array
<scramb>.randomArr(array)
Making ID.
const number = // number for id length
<scramb>.makeId(number)
Random Password.
const number = // number for id length
<scramb>.passGen(number)
Making ID.
<scramb>.randomString('STRING', 'NUMBER OF LENGTH')
is String?
<scramb>.isString(SOME VALUE)
is Number?
<scramb>.isNumber(SOME VALUE)
The result is a random number between <min> and <max>
<scramb>.minMax("min number", "max number")
Generate random user agent
<scramb>.userAgents()
is Email?
<scramb>.isEmail("STRING")
is URL?
<scramb>.isURL("STRING")
rps
<scramb>.rps()
like the makeId function but here only numbers.
<scramb>.makeidNumber("LENGTH")
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 the given array.
const arr = //array
<scramb>.shuffle(arr)
Flip a coin!
<scramb>.coin() // results will be random between heads and tails
is youtube url?
<scramb>.isYoutubeURL("url")
is instagram url?
<scramb>.isInstagramURL("url")
is soundcloud url?
<scramb>.isSoundcloudURL("url")
v3.0.6 - From contributor (ThisMe124)
<scramb>.isYoutubeURL()
<scramb>.isInstagramURL()
<scramb>.isSoundcloudURL()
<scramb>.makeidNumber("length")
- From contributor (ThisMe124)
<scramb>.magicConchShell()
<scramb>.shuffle(["array"])
<scramb>.coin()
<scramb>.falsy()
<scramb>.userAgents()
<scramb>.isEmail("STRING")
<scramb>.isURL("STRING")
<scramb>.rps()
<scramb>.isNumber()
<scramb>.isString()
<scramb>.minMax()