Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-random-generator

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-random-generator - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

41

index.js

@@ -10,2 +10,20 @@ /*

function getRandomNumberBetween(min,max) {
try
{
if(!min) {
console.log("Error on getting random number! Enter minimum value")
return null;
} else if(!max) {
console.log("Error on getting random number! Enter maximum value")
return null;
}
return Math.floor(Math.random() * (max - min) + min);
}
catch(e) {
console.log("Error on getting random number between min and max! "+e.message);
return null;
}
}
function generateRandomNumber(length) {

@@ -17,3 +35,3 @@

console.log("Error on generating random number! Enter a length")
return "";
return null;
}

@@ -32,3 +50,3 @@ let result = '';

console.log("Error on generating random number! "+e.message);
return "";
return null;
}

@@ -43,3 +61,3 @@ }

console.log("Error on generating random text! Enter a length")
return "";
return null;
}

@@ -59,3 +77,3 @@ let result = '';

console.log("Error on generating random text! "+e.message);
return "";
return null;
}

@@ -70,3 +88,3 @@ }

console.log("Error on generating random password! Enter a length")
return "";
return null;
}

@@ -85,3 +103,3 @@ let result = '';

console.log("Error on generating random password! "+e.message);
return "";
return null;
}

@@ -96,10 +114,10 @@ }

console.log("Error on generating random! Enter a length")
return "";
return null;
}
if(!charSet) {
console.log("Error on generating random! Enter a character set")
return "";
return null;
} else if(charSet.length==0) {
console.log("Error on generating random! Character set is empty");
return "";
return null;
}

@@ -117,3 +135,3 @@ let result = '';

console.log("Error on generating random! "+e.message);
return "";
return null;
}

@@ -127,3 +145,4 @@ }

generateRandomPassword: generateRandomPassword,
generateRandom: generateRandom
generateRandom: generateRandom,
getRandomNumberBetween: getRandomNumberBetween
}
{
"name": "js-random-generator",
"version": "1.0.2",
"version": "1.0.3",
"description": "Useful Random Generator",

@@ -5,0 +5,0 @@ "main": "index.js",

# js-random-generator
You can generate random number, text, password or value that you want with custom length easily.
***

@@ -21,6 +20,12 @@ ### List of Features

```js
const {generateRandom, generateRandomNumber, generateRandomText, generateRandomPassword} = require('js-random-generator')
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 characterSet = 'qwerasdfzxcv' // custom character set

@@ -39,5 +44,11 @@ const randomNumber = generateRandomNumber(length)

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
```

@@ -44,0 +55,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc