js-random-generator
v1.0.4
Published
Useful Random Generator
Downloads
54,062
Maintainers
Readme
js-random-generator
You can generate random number, text, password or value that you want with custom length easily.
List of Features
- Generate a random number (custom length)
- Generate a random text (custom length)
- Generate a random password (custom length)
- Generate a random value (custom length)
Download & Installation
$ npm i js-random-generator
Example Usage
const {generateRandom, generateRandomNumber, generateRandomText, generateRandomPassword, getRandomNumberBetween} = require('js-random-generator')
const min = 5
const max = 10
const randomNumberBetween = getRandomNumberBetween(min,max)
console.log(randomNumberBetween) // output: 7
const length = 8 // custom length
const randomNumber = generateRandomNumber(length)
console.log(randomNumber) // output: 10462678
const randomTextOnlyUpper = generateRandomText(length,false) // only upper case characters
console.log(randomTextOnlyUpper) // output: EBLKEWMK
const randomTextWithLower = generateRandomText(length,true) // includes lower case characters
console.log(randomTextWithLower) // output: EPugSiwN
const randomPassword = generateRandomPassword(length)
console.log(randomPassword) // output: y7SHvb_Q
const characterSet = 'qwerasdfzxcv' // custom character set
const randomValue = generateRandom(length,characterSet) // you can generate a random value with your custom character set
console.log(randomValue) // output: dcwzavdr
// Error => returns null
License
This project is licensed under the MIT License