Fastrandom
Made for your faster random needs
Fastrandom works by pregenerating an array of random values and later returns values from the array.



Usage
npm
In your project, run the following command:
npm install fastrandom --save
Require as module
var random = require('fastrandom');
var value = random();
Use in browser
<script type="text/javascript" src="./src/random.js"></script>
<script type="text/javascript" src="./dist/random.js"></script>
<script>
var value = random();
</script>
Browser using AMD or RequireJS
define(function (require) {
var random = require("fastrandom");
var value = random();
});
define(["fastrandom"], function (random) {
var value = random();
});
From CLI
npm install fastrandom -g
fastrandom
Basic usage
random();
Other functions
random.options
random.randomChanger();
random.random
random.randomArray
random.currentRandomIndex
Support
Tested with:
- Safari 8.0.7 (OSX)
- Chrome 44.0.2403.125 (PC)
- Chrome 44.0.2403.107 (OSX)
- Firefox 37 (PC)
- Firefox 38 (PC)
- Firefox 39 (OSX)
- Microsoft Edge
Options
Define window.fastrandomOptions
before requiring the script.
Default options:
window.fastrandomOptions = {
valuesCount: 10000,
randomInterval: 30
removeOptions: true
};
Shoutout!
If there is someone who knows how to write tests then fork it and do a pull request after! Thank you! I will add people who contribute to contributors and credits!
Development
First you should install dependencies
npm install
Do your magic ;) (add features, fix bugs, etc) All the code is in the src
folder, dist
folder contains minified version of the src.
Run default gulp task for minfication:
gulp
Jasmine tests by running:
npm test
License
ISC