This package has been deprecated

Author message:

Fastrandom is deprecated as it was only an experiment and is not really needed in real life.

fastrandom

1.1.15 • Public • Published

Fastrandom

Made for your faster random needs

Fastrandom works by pregenerating an array of random values and later returns values from the array.

NPM

Build Status

Twitter

Usage

npm

In your project, run the following command:

npm install fastrandom --save
Require as module
var random = require('fastrandom');
var value = random(); // random value like Math.random();
Use in browser
<!-- Source -->
<script type="text/javascript" src="./src/random.js"></script>
<!-- Minified -->
<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(); // returns a random value like Math.random();
Other functions
// Returns object of current options
random.options
 
// generates a new random value to array changing out an old one in current index
random.randomChanger();
 
// If browser supports getters and setters then there is also:
// getter version of the random
random.random // returns a random value like Math.random(); works the same like random();
 
// array that contains current random values
random.randomArray // [0.1414, 0.91325, ...];
 
// Current index in the random array
random.currentRandomIndex // 0 ... n

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,   // How many random values should be generated at init, more values mean less looping
    randomInterval: 30    // Interval, how often a new random value is generated (in ms),
    removeOptions: true   // if true then global window.fastrandomOptions will be deleted after init
};

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

Package Sidebar

Install

npm i fastrandom

Weekly Downloads

4

Version

1.1.15

License

ISC

Last publish

Collaborators

  • hendrysadrak