Socket
Socket
Sign inDemoInstall

random-seed

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

.travis.yml

20

lib/random-seed.js

@@ -225,2 +225,22 @@ /*

// Returns a random integer between 0 (inclusive) and range (exclusive)
random.range = function (range) {
return random(range);
};
// Returns a random float between 0 (inclusive) and 1 (exclusive)
random.random = function () {
return random(Number.MAX_VALUE - 1) / Number.MAX_VALUE;
};
// Returns a random float between min (inclusive) and max (exclusive)
random.floatBetween = function (min, max) {
return random.random() * (max - min) + min;
};
// Returns a random integer between min (inclusive) and max (inclusive)
random.intBetween = function (min, max) {
return Math.floor(random.random() * (max - min + 1)) + min;
};
// when our main outer "uheprng" function is called, after setting up our

@@ -227,0 +247,0 @@ // initial variables and entropic state, we return an "instance pointer"

12

package.json
{
"name": "random-seed",
"description": "GRC's UHE PRNG in node (Ultra-High Entropy Pseudo-Random Number Generator by Gibson Research Corporation)",
"version": "0.1.0",
"version": "0.2.0",
"homepage": "https://github.com/skratchdot/random-seed",

@@ -28,9 +28,9 @@ "author" : "skratchdot",

"scripts": {
"test": "grunt nodeunit"
"test": "grunt test"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt-contrib-watch": "~0.2.0",
"grunt": "~0.4.1"
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.4.0",
"grunt-contrib-watch": "~0.6.1",
"grunt": "~0.4.5"
},

@@ -37,0 +37,0 @@ "keywords": [

# random-seed
[![Build Status](https://travis-ci.org/skratchdot/random-seed.png?branch=master)](https://travis-ci.org/skratchdot/random-seed)
[![Coverage Status](https://coveralls.io/repos/skratchdot/random-seed/badge.png)](https://coveralls.io/r/skratchdot/random-seed)
[![devDependency Status](https://david-dm.org/skratchdot/random-seed/dev-status.svg)](https://david-dm.org/skratchdot/random-seed#info=devDependencies)
Gibson Research Corporation's Ultra-High Entropy Pseudo-Random Number Generator

@@ -13,3 +17,10 @@ ported to node.

I've also added the following helper methods:
- random()
- range(range)
- floatBetween(min, max)
- intBetween(min, max)
## Getting Started

@@ -24,2 +35,3 @@

## Documentation

@@ -55,5 +67,24 @@

#### rand(num)
#### rand(range)
Returns a random integer between 0 (inclusive) and range (exclusive)
#### rand.range(range)
Returns a random integer between 0 (inclusive) and range (exclusive)
#### rand.random()
Returns a random float between 0 (inclusive) and 1 (exclusive)
Works the same as Math.random()
#### rand.floatBetween(min, max)
Returns a random float between min (inclusive) and max (exclusive)
#### rand.intBetween(min, max)
Returns a random integer between min (inclusive) and max (inclusive)
#### rand.seed(seed)

@@ -103,3 +134,3 @@

### Default Usage: print 1 random number between 0 - 99
### Default Usage: create 1 random number between 0 - 99
```javascript

@@ -110,3 +141,3 @@ var rand = require('random-seed').create();

### Always print same sequence of random numbers
### Always create same sequence of random numbers
```javascript

@@ -136,7 +167,23 @@ var rand = require('random-seed').create();

### Replace Math.random()
```javascript
var math = require('random-seed').create();
console.log(math.random());
```
## Release History
- v0.1.0 (Released October 26, 2013)
#### v0.2.0 (Released June 1, 2014)
- Adding the following helper methods:
- rand.random(min, max)
- rand.floatBetween(min, max)
- rand.intBetween(min, max)
#### v0.1.0 (Released October 26, 2013)
- Initial Release
## License

@@ -143,0 +190,0 @@

@@ -22,2 +22,3 @@ 'use strict';

*/
var testLoop = 10000;

@@ -89,1 +90,56 @@ exports['no args'] = function (test) {

};
exports['random() >=0 && < 1'] = function (test) {
var rand = require('../lib/random-seed.js').create(),
val, i;
test.expect(testLoop);
for (i = 0; i < testLoop; i++) {
val = rand.random();
test.ok(val >= 0 && val < 1, 'random() is >=0 and < 1');
}
test.done();
};
exports['intBetween(5, 10) >=5 && <= 10'] = function (test) {
var rand = require('../lib/random-seed.js').create(),
val, i;
test.expect(testLoop);
for (i = 0; i < testLoop; i++) {
val = rand.random();
test.ok(val >= 0 && val < 1, 'random() is >=0 and < 1');
}
test.done();
};
exports['intBetween(-5, 5) >=-5 && <= 5'] = function (test) {
var rand = require('../lib/random-seed.js').create(),
val, i;
test.expect(testLoop);
for (i = 0; i < testLoop; i++) {
val = rand.random();
test.ok(val >= 0 && val < 1, 'random() is >=0 and < 1');
}
test.done();
};
exports['floatBetween(5, 10) >=5 && < 10'] = function (test) {
var rand = require('../lib/random-seed.js').create(),
val, i;
test.expect(testLoop);
for (i = 0; i < testLoop; i++) {
val = rand.random();
test.ok(val >= 0 && val < 1, 'random() is >=0 and < 1');
}
test.done();
};
exports['floatBetween(-5, 5) >=-5 && < 5'] = function (test) {
var rand = require('../lib/random-seed.js').create(),
val, i;
test.expect(testLoop);
for (i = 0; i < testLoop; i++) {
val = rand.random();
test.ok(val >= 0 && val < 1, 'random() is >=0 and < 1');
}
test.done();
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc