Socket
Book a DemoInstallSign in
Socket

fastrandom

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastrandom

Faster random function - Made for your faster random needs

1.1.15
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

random

FAQs

Package last updated on 02 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.