0.1.0 • Published 10 years ago

random.js v0.1.0

Weekly downloads
189
License
-
Repository
github
Last release
10 years ago

random.js

javascript random numbers and string generation library

usage:

use it from your html page:

	<script type="text/javascript" src="random.js"></script>

or from a node.js project

	// in your package.json
	dependencies: [
		"random.js": "0.1.0"
	]
	// in your js file
	var random = require('random')

functions:

  • randomInt([options]): generate random integers
    parameters: options:Object min:Int:
    the minimum value (default: 0)
    max:Int:
    the maximum value (default: 4294967295) * returns: an integer between the min/max bounds

  • randomFloat([options]): generate random floats parameters: options:Object: min:Float:
    the minimum value (default: 0.0)
    max:Float:
    the maximum value (default: 1.0) * returns an integer between the min/max bounds

  • randomString([options]): generate random strings parameters: options:Object length:Int:
    the length of the string to generate (default: 20)
    set:String:
    one of "alpha" | "numeric" | "alphanum" | "hex" | "custom" (default: "alphanum") custom:String/Array<char>:
    if set is "custom", provides a set of characters used for the string generation
    returns a string containing random characters from the selected set of the given length * note: when generating hexadecimal strings, the alpha-characters are uppercase, use .toLowerCase() on the result to switch to lowercase