This is a dependency free random crap generator. Currently it handles getting random simple random ints, but I will be adding stuff to it as I need it for my other projects.
This has more entropy than Math.random()
but isn't going to be adequate for crypto. For that I suggest GRC javascript peudo-random number generator or Web Cryptography API.
- random int
- random from set
- random float
- random alpha
- random alpha numeric
- random emoji
This is meant to be a flexible yet not cryptography sound random number generator. The numbers should look good, and the bias is adjustable. A high bias will yield higher random numbers from sets. This bias can be set through the constructor or through a setter function.
- RandomCrap
Class for generation of RandomCrap.
Please do not complain about these numbers not being "true" random. The point behind doing this isn't to have correct math, but instead to generate numbers that are fun. This is why the bais exists and can be adjusted. This way the developer can influence the result to adjust the fun.
- NORMAL_BIAS :
Number
The Normal Bias needed to create centered Random Number Generation.
- HIGH_ADJUSTER :
Number
The High end on which the random number will be adjusted for randomness.
- LOW_ADJUSTER :
Number
The High end on which the random number will be adjusted for randomness.
Class for generation of RandomCrap.
Please do not complain about these numbers not being "true" random. The point behind doing this isn't to have correct math, but instead to generate numbers that are fun. This is why the bais exists and can be adjusted. This way the developer can influence the result to adjust the fun.
Kind: global class
Param | Type | Default | Description |
---|---|---|---|
[biasAdjuster] | Float |
"NORMAL_BIAS" |
Allows setting a high or low bias for random generation. |
Sets the current random bias.
Kind: instance method of RandomCrap
Param | Type | Default | Description |
---|---|---|---|
[bias] | Float |
"NORMAL_BIAS" |
Allows setting a high or low bias for random generation. Setting nothing will reset to neutral bias. |
Returns the current bias.
Kind: instance method of RandomCrap
Gets a random element from a supplied set.
Kind: instance method of RandomCrap
Param | Type | Default | Description |
---|---|---|---|
set | Array |
The set from which to pull a random element. | |
[name] | String |
"__default" |
The name of the set, if this is set then the random element will be removed as a possible element in future calls. |
[loop] | Boolean |
"false" |
Append the original set back onto the end if the set is empty. |
Returns a random alpha character.
Kind: instance method of RandomCrap
Param | Type | Default | Description |
---|---|---|---|
options | Object |
Optional arguments. | |
[options.allCaps] | Boolean |
"false" |
Only return Capitalized letters. |
[options.noCaps] | Boolean |
"false" |
Never return Capitalized letters. |
[options._set] | Array |
"[a, b, c, ... z]" |
Inject set, useful for testing, or localization. |
Returns a simple random floating point Number.
Kind: instance method of RandomCrap
Param | Type | Description |
---|---|---|
wholePrecision | Integer |
The number of precision to the left of the decimal point. |
floatPrecision | Integer |
The number of precision to the right of the decimal point. |
Returns a random integer from min (inclusive) to max (inclusive).
Kind: instance method of RandomCrap
Param | Type | Description |
---|---|---|
min | Integer |
The lowest number to return. |
max | Integer |
The highest number to return. |
The Normal Bias needed to create centered Random Number Generation.
The High end on which the random number will be adjusted for randomness.
The High end on which the random number will be adjusted for randomness.
Kind: global constant