randomize-unique

0.0.4 • Public • Published

Installation

$ npm install randomize

Usage

Random Integer:

2 Parameters.

  1. minNumber - optional (Default value : 1)
  2. 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));
//» 441
//» 568
 
## `if you want 4 digit random code than use like this:`
 
console.log(randomize.randomInteger(1000, 9999));
//» 5036
//» 6493
 
## `if you want 6 digit random code than use like this:`
 
console.log(randomize.randomInteger(100000, 999999));
//» 539864
//» 459781
 

Random Float:

3 Parameters.

  1. minNumber - optional (Default value : 1)
  2. maxNumber - optional (Default value : 10000)
  3. 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));
//» 441.32
//» 568.45
 
## `if you want 4 digit random float code than use like this:`
 
console.log(randomize.randomFloat(1000, 9999));
//» 5036.32
//» 6493.65
 
## `if you want 3 number after .(dot) than use like this:`
 
console.log(randomize.randomFloat(1000, 9999, 3));
//» 5036.327
//» 6493.651
 
## `if you want 1 number after .(dot) than use like this:`
 
console.log(randomize.randomFloat(1000, 9999, 1));
//» 5036.3
//» 6493.6
 

Random Boolean:

Syntax : randomBoolean()

var randomize = require("randomize-unique");
 
console.log(randomize.randomBoolean());
//» false
//» true
//» true
//» false

Random String or Random Password Generator:

4 Parameters.

  1. length - optional (Default value : 8)
  2. isCapitalAllow - optional (Default value : false)
  3. isNumberAllow - optional (Default value : false)
  4. isSpecialCharAllow - optional (Default value : false)

Syntax : randomString(length, isCapitalAllow, isNumberAllow, isSpecialCharAllow)

var randomize = require("randomize-unique");
 
console.log(randomize.randomString());
//» wltvqprk
 
## `if you want 10 character random string than use like this:`
 
console.log(randomize.randomString(10));
//» rqmflwrusp
 
## `if you want capital letter in random string than use like this:`
 
console.log(randomize.randomString(8,true));
//» kYbQYlpoX
 
## `if you want capital letter and digit in random string than use like this:`
 
console.log(randomize.randomString(8, true, true));
//» 6YbQ9lpoX
 
 
## `if you want capital letter, digit and special character in random string than use like this:`
 
console.log(randomize.randomString(8, true, true, true));
//» 6Je*w#Lq
 

Random Array:

1 Parameters.

  1. length - optional (Default value : 10)

Syntax : randomArray(length)

var randomize = require("randomize-unique");
 
console.log(randomize.randomArray());
//» [1,44,56,32,87,71,41,69,51,70]
 
## `if you want 5 element in array than use like this:`
 
console.log(randomize.randomArray(5));
//» [1,44,56,32,87]
 

Random String Array:

4 Parameters.

  1. length - optional (Default value : 5)
  2. minStringLength - optional (Default value : 5)
  3. maxStringLength - optional (Default value : 10)
  4. isSpaceAllow - optional (Default value : true)

Syntax : randomStringArray(length, minStringLength, maxStringLength, isSpaceAllow)

var randomize = require("randomize-unique");
 
console.log(randomize.randomStringArray());
//» ['A Q','kMhg na','HRtmFGu','lc GWR',' O A ca']
 
## `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));
//» ['s EvprF lJx kE',' QsWuyjjcEDt e',' aVdAGjhveSbN']
 

Random or Unique Image Name:

2 Parameters.

  1. prefix - optional (Default value : "")
  2. suffix - optional (Default value : "")

Syntax : uniqueImageName(prefix, suffix)

var randomize = require("randomize-unique");
 
console.log(randomize.uniqueImageName());
//» 1591685161249
 
## `if you want prefix in image name than use like this:`
 
console.log(randomize.uniqueImageName("profile_"));
//» profile_1591685161249
 
## `if you want suffix in image name than use like this:`
 
console.log(randomize.uniqueImageName("","_img"));
//» 1591685161249_img
 
## `if you want prefix and suffix in image name than use like this:`
 
console.log(randomize.uniqueImageName("profile_","_img"));
//» profile_1591685161249_img
 

Random RGB Color:

Syntax : randomRGBColor()

var randomize = require("randomize-unique");
 
console.log(randomize.randomRGBColor());
//» rgb(255, 10, 34)
 

Random HEX Color:

Syntax : randomHEXColor()

var randomize = require("randomize-unique");
 
console.log(randomize.randomHEXColor());
//» #ff0000
 

Random HSL Color:

Syntax : randomHSLColor()

var randomize = require("randomize-unique");
 
console.log(randomize.randomHSLColor());
//» hsl(0, 100%, 50%)
 

Who contributed?

[ anil_bhadani99 ]

Package Sidebar

Install

npm i randomize-unique

Weekly Downloads

1

Version

0.0.4

License

ISC

Unpacked Size

8.64 kB

Total Files

3

Last publish

Collaborators

  • anil_bhadani99