GithubHelp home page GithubHelp logo

randstorm's Introduction

randstorm

Random values generator for different data types

Installation

Just clone the repo and copy the file randstorm.js into the folder of your convenience

Usage

  1. Require it and assign to a variable
var rs = require('randstorm');
  1. Call the desired method on it.
console.log(rs.nativeRandom());

API

nativeRandom():

  • Currently a wrapper of Math.random
  • Returns: a number between 0 and 1

integerNumber([min], [max]):

  • Returns an integer number between min and max.
  • min (optional): Minimum desired value (defaults to Number.MIN_SAFE_INTEGER)
  • max (optional): Maximum desired value (defaults to Number.MAX_SAFE_INTEGER)

naturalNumber([max]):

  • Returns a positive integer number up to
  • max (optional): Maximum desired value (defaults to Number.MAX_SAFE_INTEGER)

bool():

  • Returns either true or false randomly

utf8Char();

  • Returns a random character from the utf8 range

asciiChar():

  • Returns a random ASCII character

alphabetChar():

  • Returns a random character from the alphabet, either upper case or lower case

alphaNumericChar():

  • Returns a random character from the alphabet and from the 0-9 range

hexChar():

  • Returns a random character from the hexadecmal notation [0-9],[a-f]

utf8String(length):

  • Returns a sequence of random utf8 characters
  • length is mandatory and must be a positive integer number, otherwise "Invalid string length" exception s thrown

asciiString(length):

  • Returns a sequence of random ASCII characters
  • length is mandatory and must be a positive integer number, otherwise "Invalid string length" exception s thrown

alphabetString(length):

  • Returns a sequence of random characters from the alphabet using upper case and lower case letters
  • length is mandatory and must be a positive integer number, otherwise "Invalid string length" exception s thrown

alphaNumericString(length):

  • Returns a sequence of random characters from the alphabet and the 0-9 range using upper case and lower case letters
  • length is mandatory and must be a positive integer number, otherwise "Invalid string length" exception s thrown

hexString(length):

  • Returns a sequence of random characters from the hexadecimal notation
  • length is mandatory and must be a positive integer number, otherwise "Invalid string length" exception s thrown

url(length, [scheme]):

  • Returns a url-like string with the following form: scheme+domain_name.top_level_domain/endpoint where:
  • scheme (optional): defaults to http://
  • domain_name: random alphanumeric string of <lenght / 2> charachters
  • top_level_domain: randomly picked from the list shown below
  • endpoint: random alphanumeric string of <lenght / 2> charachters
  • length is mandatory and must be a positive integer number, otherwise "Invalid string length" exception s thrown
  • Top-level domains available: .example, .invalid, .local, .localhost, .onion, .test, .com, .org, .net, .int, .edu, .gov, .io, .mil

Limitations

The correct mathematical distibution of the values generated has not been tested.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.