Installation
$ npm install randomize
Usage
Random Integer:
2 Parameters.
- minNumber - optional (Default value : 1)
- maxNumber - optional (Default value : 100)
Syntax : randomInteger(minNumber, maxNumber)
var randomize = require("randomize-unique");
## `if you want 3 digit random code than use like this:`
console.log(randomize.randomInteger(100, 999));
## `if you want 4 digit random code than use like this:`
console.log(randomize.randomInteger(1000, 9999));
## `if you want 6 digit random code than use like this:`
console.log(randomize.randomInteger(100000, 999999));
Random Float:
3 Parameters.
- minNumber - optional (Default value : 1)
- maxNumber - optional (Default value : 10000)
- fraction - optional (Default value : 2)
Syntax : randomFloat(minNumber, maxNumber, fraction)
var randomize = require("randomize-unique");
## `if you want 3 digit random float code than use like this:`
console.log(randomize.randomFloat(100, 999));
## `if you want 4 digit random float code than use like this:`
console.log(randomize.randomFloat(1000, 9999));
## `if you want 3 number after .(dot) than use like this:`
console.log(randomize.randomFloat(1000, 9999, 3));
## `if you want 1 number after .(dot) than use like this:`
console.log(randomize.randomFloat(1000, 9999, 1));
Random Boolean:
Syntax : randomBoolean()
var randomize = require("randomize-unique");
console.log(randomize.randomBoolean());
Random String or Random Password Generator:
4 Parameters.
- length - optional (Default value : 8)
- isCapitalAllow - optional (Default value : false)
- isNumberAllow - optional (Default value : false)
- isSpecialCharAllow - optional (Default value : false)
Syntax : randomString(length, isCapitalAllow, isNumberAllow, isSpecialCharAllow)
var randomize = require("randomize-unique");
console.log(randomize.randomString());
## `if you want 10 character random string than use like this:`
console.log(randomize.randomString(10));
## `if you want capital letter in random string than use like this:`
console.log(randomize.randomString(8,true));
## `if you want capital letter and digit in random string than use like this:`
console.log(randomize.randomString(8, true, true));
## `if you want capital letter, digit and special character in random string than use like this:`
console.log(randomize.randomString(8, true, true, true));
Random Array:
1 Parameters.
- length - optional (Default value : 10)
Syntax : randomArray(length)
var randomize = require("randomize-unique");
console.log(randomize.randomArray());
## `if you want 5 element in array than use like this:`
console.log(randomize.randomArray(5));
Random String Array:
4 Parameters.
- length - optional (Default value : 5)
- minStringLength - optional (Default value : 5)
- maxStringLength - optional (Default value : 10)
- isSpaceAllow - optional (Default value : true)
Syntax : randomStringArray(length, minStringLength, maxStringLength, isSpaceAllow)
var randomize = require("randomize-unique");
console.log(randomize.randomStringArray());
## `if you want 3 element and string length is in between 10 to 20 in array than use like this:`
console.log(randomize.randomStringArray(3, 10, 20));
Random or Unique Image Name:
2 Parameters.
- prefix - optional (Default value : "")
- suffix - optional (Default value : "")
Syntax : uniqueImageName(prefix, suffix)
var randomize = require("randomize-unique");
console.log(randomize.uniqueImageName());
## `if you want prefix in image name than use like this:`
console.log(randomize.uniqueImageName("profile_"));
## `if you want suffix in image name than use like this:`
console.log(randomize.uniqueImageName("","_img"));
## `if you want prefix and suffix in image name than use like this:`
console.log(randomize.uniqueImageName("profile_","_img"));
Random RGB Color:
Syntax : randomRGBColor()
var randomize = require("randomize-unique");
console.log(randomize.randomRGBColor());
Random HEX Color:
Syntax : randomHEXColor()
var randomize = require("randomize-unique");
console.log(randomize.randomHEXColor());
Random HSL Color:
Syntax : randomHSLColor()
var randomize = require("randomize-unique");
console.log(randomize.randomHSLColor());
Who contributed?
[ anil_bhadani99 ]