first commit
This commit is contained in:
1
build/node_modules/seedrandom/.coveralls.yml
generated
vendored
Normal file
1
build/node_modules/seedrandom/.coveralls.yml
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
service_name: travis-ci
|
||||
2
build/node_modules/seedrandom/.npmignore
generated
vendored
Normal file
2
build/node_modules/seedrandom/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
bower_components
|
||||
1
build/node_modules/seedrandom/.nvmrc
generated
vendored
Normal file
1
build/node_modules/seedrandom/.nvmrc
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
6
|
||||
9
build/node_modules/seedrandom/.travis.yml
generated
vendored
Normal file
9
build/node_modules/seedrandom/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- '0.10'
|
||||
- '0.12'
|
||||
- '4'
|
||||
- '5'
|
||||
- '6'
|
||||
- '7'
|
||||
108
build/node_modules/seedrandom/Gruntfile.js
generated
vendored
Normal file
108
build/node_modules/seedrandom/Gruntfile.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
module.exports = function(grunt) {
|
||||
"use strict";
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON("package.json"),
|
||||
bowercopy: {
|
||||
options: {
|
||||
clean: true
|
||||
},
|
||||
test: {
|
||||
options: {
|
||||
destPrefix: "test/lib"
|
||||
},
|
||||
files: {
|
||||
"qunit.js" : "qunit/qunit/qunit.js",
|
||||
"qunit.css" : "qunit/qunit/qunit.css",
|
||||
"require.js" : "requirejs/require.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
all: {
|
||||
files: {
|
||||
"<%= pkg.name %>.min.js": [ "<%= pkg.name %>.js" ],
|
||||
"lib/alea.min.js": [ "lib/alea.js" ],
|
||||
"lib/tychei.min.js": [ "lib/tychei.js" ],
|
||||
"lib/xor4096.min.js": [ "lib/xor4096.js" ],
|
||||
"lib/xorshift7.min.js": [ "lib/xorshift7.js" ],
|
||||
"lib/xorwow.min.js": [ "lib/xorwow.js" ],
|
||||
"lib/xor128.min.js": [ "lib/xor128.js" ]
|
||||
},
|
||||
options: {
|
||||
preserveComments: false,
|
||||
report: "min",
|
||||
beautify: {
|
||||
ascii_only: true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
qunit: {
|
||||
options: {
|
||||
noGlobals: true,
|
||||
httpBase: 'http://localhost:8192'
|
||||
},
|
||||
all: ["test/*.html"]
|
||||
},
|
||||
connect: {
|
||||
server: {
|
||||
options: {
|
||||
port: 8192,
|
||||
base: '.'
|
||||
}
|
||||
}
|
||||
},
|
||||
browserify: {
|
||||
test: {
|
||||
files: {
|
||||
'test/browserified.js': ['test/nodetest.js'],
|
||||
},
|
||||
options: {
|
||||
ignore: ['requirejs', 'process'],
|
||||
alias: {
|
||||
'assert': './test/qunitassert.js'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mochacov: {
|
||||
options: {
|
||||
files: [
|
||||
'test/cryptotest.js',
|
||||
'test/nodetest.js',
|
||||
'test/prngtest.js'
|
||||
]
|
||||
},
|
||||
coverage: {
|
||||
options: {
|
||||
coveralls: true
|
||||
}
|
||||
},
|
||||
test: {
|
||||
options: {
|
||||
reporter: 'dot'
|
||||
}
|
||||
}
|
||||
},
|
||||
release: {
|
||||
options: {
|
||||
bump: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-bowercopy');
|
||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||
grunt.loadNpmTasks('grunt-contrib-qunit');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-mocha-cov');
|
||||
grunt.loadNpmTasks('grunt-release');
|
||||
grunt.loadNpmTasks('grunt-browserify');
|
||||
|
||||
grunt.registerTask("test",
|
||||
["browserify", "connect", "qunit", "mochacov:test"]);
|
||||
grunt.registerTask("default", ["uglify", "test"]);
|
||||
grunt.registerTask("travis", ["default", "mochacov:coverage"]);
|
||||
};
|
||||
|
||||
298
build/node_modules/seedrandom/README.md
generated
vendored
Normal file
298
build/node_modules/seedrandom/README.md
generated
vendored
Normal file
@@ -0,0 +1,298 @@
|
||||
seedrandom.js
|
||||
=============
|
||||
[](https://travis-ci.org/davidbau/seedrandom)
|
||||
[](http://badge.fury.io/js/seedrandom)
|
||||
[](http://badge.fury.io/bo/seedrandom)
|
||||
|
||||
Seeded random number generator for JavaScript.
|
||||
|
||||
Version 2.4.3
|
||||
|
||||
Author: David Bau
|
||||
|
||||
Date: 2015-07-04
|
||||
|
||||
Can be used as a plain script, a Node.js module or an AMD module.
|
||||
|
||||
|
||||
Script tag usage
|
||||
----------------
|
||||
|
||||
```html
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.4.3/seedrandom.min.js">
|
||||
</script>
|
||||
```
|
||||
|
||||
```js
|
||||
// Sets Math.random to a PRNG initialized using the given explicit seed.
|
||||
Math.seedrandom('hello.');
|
||||
console.log(Math.random()); // Always 0.9282578795792454
|
||||
console.log(Math.random()); // Always 0.3752569768646784
|
||||
|
||||
// Sets Math.random to an ARC4-based PRNG that is autoseeded using the
|
||||
// current time, dom state, and other accumulated local entropy.
|
||||
// The generated seed string is returned.
|
||||
Math.seedrandom();
|
||||
console.log(Math.random()); // Reasonably unpredictable.
|
||||
|
||||
// Seeds using the given explicit seed mixed with accumulated entropy.
|
||||
Math.seedrandom('added entropy.', { entropy: true });
|
||||
console.log(Math.random()); // As unpredictable as added entropy.
|
||||
|
||||
// Use "new" to create a local prng without altering Math.random.
|
||||
var myrng = new Math.seedrandom('hello.');
|
||||
console.log(myrng()); // Always 0.9282578795792454
|
||||
|
||||
// Use "quick" to get only 32 bits of randomness in a float.
|
||||
console.log(myrng.quick()); // Always 0.3752569768112153
|
||||
|
||||
// Use "int32" to get a 32 bit (signed) integer
|
||||
console.log(myrng.int32()); // Always 986220731
|
||||
|
||||
```
|
||||
|
||||
Other Fast PRNG Algorithms
|
||||
--------------------------
|
||||
|
||||
The package includes some other fast PRNGs. To use Johannes Baagøe's
|
||||
extremely fast Alea PRNG:
|
||||
|
||||
|
||||
```html
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.4.3/lib/alea.min.js">
|
||||
</script>
|
||||
```
|
||||
|
||||
```js
|
||||
// Use xor4096 for Richard Brent's xorgens-4096 algorithm.
|
||||
var xorgen = new xor4096('hello.');
|
||||
|
||||
// By default provides 32 bits of randomness in a float.
|
||||
console.log(xorgen()); // Always 0.9798525865189731
|
||||
|
||||
// Use "double" to get 56 bits of randomness.
|
||||
console.log(xorgen.double()); // Always 0.03583478477375346
|
||||
|
||||
// Use "int32" to get a 32 bit (signed) integer.
|
||||
console.log(xorgen.int32()); // Always 1341429986
|
||||
````
|
||||
|
||||
Besides xor4096, there are several other faster PRNGs available.
|
||||
|
||||
|PRNG name | Time vs native | Period | Author |
|
||||
|-----------|----------------|-------------|----------------------|
|
||||
|`alea` | 1.95 ns, 0.9x | ~2^116 | Baagøe |
|
||||
|`xor128` | 2.04 ns, 0.9x | 2^128-1 | Marsaglia |
|
||||
|`tychei` | 2.32 ns, 1.1x | ~2^127 | Neves/Araujo (ChaCha)|
|
||||
|`xorwow` | 2.40 ns, 1.1x | 2^192-2^32 | Marsaglia |
|
||||
|`xor4096` | 2.40 ns, 1.1x | 2^4096-2^32 | Brent (xorgens) |
|
||||
|`xorshift7`| 2.64 ns, 1.3x | 2^256-1 | Panneton/L'ecuyer |
|
||||
|`quick` | 3.80 ns, 1.8x | ~2^1600 | Bau (ARC4) |
|
||||
|
||||
(Timings were done on node v0.12.2 on a single-core Google Compute Engine
|
||||
instance. `quick` is just the 32-bit version of the RC4-based PRNG
|
||||
originally packaged with seedrandom.)
|
||||
|
||||
|
||||
Node.js usage
|
||||
-------------
|
||||
|
||||
```
|
||||
npm install seedrandom
|
||||
```
|
||||
|
||||
```js
|
||||
// Local PRNG: does not affect Math.random.
|
||||
var seedrandom = require('seedrandom');
|
||||
var rng = seedrandom('hello.');
|
||||
console.log(rng()); // Always 0.9282578795792454
|
||||
|
||||
// Global PRNG: set Math.random.
|
||||
seedrandom('hello.', { global: true });
|
||||
console.log(Math.random()); // Always 0.9282578795792454
|
||||
|
||||
// Autoseeded ARC4-based PRNG.
|
||||
rng = seedrandom();
|
||||
console.log(rng()); // Reasonably unpredictable.
|
||||
|
||||
// Mixing accumulated entropy.
|
||||
rng = seedrandom('added entropy.', { entropy: true });
|
||||
console.log(rng()); // As unpredictable as added entropy.
|
||||
|
||||
// Using alternate algorithms, as listed above.
|
||||
var rng2 = seedrandom.xor4096('hello.')
|
||||
console.log(rng2());
|
||||
```
|
||||
|
||||
|
||||
Require.js usage
|
||||
----------------
|
||||
|
||||
Similar to Node.js usage:
|
||||
|
||||
```
|
||||
bower install seedrandom
|
||||
```
|
||||
|
||||
```
|
||||
require(['seedrandom'], function(seedrandom) {
|
||||
var rng = seedrandom('hello.');
|
||||
console.log(rng()); // Always 0.9282578795792454
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
Network seeding
|
||||
---------------
|
||||
|
||||
```html
|
||||
<script src=//cdnjs.cloudflare.com/ajax/libs/seedrandom/2.4.3/seedrandom.min.js>
|
||||
</script>
|
||||
<!-- Seeds using urandom bits from a server. -->
|
||||
<script src=//jsonlib.appspot.com/urandom?callback=Math.seedrandom>
|
||||
</script>
|
||||
|
||||
<!-- Seeds mixing in random.org bits -->
|
||||
<script>
|
||||
(function(x, u, s){
|
||||
try {
|
||||
// Make a synchronous request to random.org.
|
||||
x.open('GET', u, false);
|
||||
x.send();
|
||||
s = unescape(x.response.trim().replace(/^|\s/g, '%'));
|
||||
} finally {
|
||||
// Seed with the response, or autoseed on failure.
|
||||
Math.seedrandom(s, !!s);
|
||||
}
|
||||
})(new XMLHttpRequest, 'https://www.random.org/integers/' +
|
||||
'?num=256&min=0&max=255&col=1&base=16&format=plain&rnd=new');
|
||||
</script>
|
||||
```
|
||||
|
||||
Reseeding using user input
|
||||
--------------------------
|
||||
|
||||
```js
|
||||
var seed = Math.seedrandom(); // Use prng with an automatic seed.
|
||||
document.write(Math.random()); // Pretty much unpredictable x.
|
||||
|
||||
var rng = new Math.seedrandom(seed); // A new prng with the same seed.
|
||||
document.write(rng()); // Repeat the 'unpredictable' x.
|
||||
|
||||
function reseed(event, count) { // Define a custom entropy collector.
|
||||
var t = [];
|
||||
function w(e) {
|
||||
t.push([e.pageX, e.pageY, +new Date]);
|
||||
if (t.length < count) { return; }
|
||||
document.removeEventListener(event, w);
|
||||
Math.seedrandom(t, { entropy: true });
|
||||
}
|
||||
document.addEventListener(event, w);
|
||||
}
|
||||
reseed('mousemove', 100); // Reseed after 100 mouse moves.
|
||||
```
|
||||
|
||||
The "pass" option can be used to get both the prng and the seed.
|
||||
The following returns both an autoseeded prng and the seed as an object,
|
||||
without mutating Math.random:
|
||||
|
||||
```js
|
||||
var obj = Math.seedrandom(null, { pass: function(prng, seed) {
|
||||
return { random: prng, seed: seed };
|
||||
}});
|
||||
```
|
||||
|
||||
|
||||
Saving and Restoring PRNG state
|
||||
-------------------------------
|
||||
|
||||
```js
|
||||
var seedrandom = Math.seedrandom;
|
||||
var saveable = seedrandom("secret-seed", {state: true});
|
||||
for (var j = 0; j < 1e5; ++j) saveable();
|
||||
var saved = saveable.state();
|
||||
var replica = seedrandom("", {state: saved});
|
||||
assert(replica() == saveable());
|
||||
```
|
||||
|
||||
In normal use the prng is opaque and its internal state cannot be accessed.
|
||||
However, if the "state" option is specified, the prng gets a state() method
|
||||
that returns a plain object the can be used to reconstruct a prng later in
|
||||
the same state (by passing that saved object back as the state option).
|
||||
|
||||
|
||||
Version notes
|
||||
-------------
|
||||
|
||||
The random number sequence is the same as version 1.0 for string seeds.
|
||||
|
||||
* Version 2.0 changed the sequence for non-string seeds.
|
||||
* Version 2.1 speeds seeding and uses window.crypto to autoseed if present.
|
||||
* Version 2.2 alters non-crypto autoseeding to sweep up entropy from plugins.
|
||||
* Version 2.3 adds support for "new", module loading, and a null seed arg.
|
||||
* Version 2.3.1 adds a build environment, module packaging, and tests.
|
||||
* Version 2.3.4 fixes bugs on IE8, and switches to MIT license.
|
||||
* Version 2.3.6 adds a readable options object argument.
|
||||
* Version 2.3.10 adds support for node.js crypto (contributed by ctd1500).
|
||||
* Version 2.3.11 adds an option to load and save internal state.
|
||||
* Version 2.4.0 adds implementations of several other fast PRNGs.
|
||||
* Version 2.4.2 adds an implementation of Baagoe's very fast Alea PRNG.
|
||||
* Version 2.4.3 ignores nodejs crypto when under browserify.
|
||||
|
||||
The standard ARC4 key scheduler cycles short keys, which means that
|
||||
seedrandom('ab') is equivalent to seedrandom('abab') and 'ababab'.
|
||||
Therefore it is a good idea to add a terminator to avoid trivial
|
||||
equivalences on short string seeds, e.g., Math.seedrandom(str + '\0').
|
||||
Starting with version 2.0, a terminator is added automatically for
|
||||
non-string seeds, so seeding with the number 111 is the same as seeding
|
||||
with '111\0'.
|
||||
|
||||
When seedrandom() is called with zero args or a null seed, it uses a
|
||||
seed drawn from the browser crypto object if present. If there is no
|
||||
crypto support, seedrandom() uses the current time, the native rng,
|
||||
and a walk of several DOM objects to collect a few bits of entropy.
|
||||
|
||||
Each time the one- or two-argument forms of seedrandom are called,
|
||||
entropy from the passed seed is accumulated in a pool to help generate
|
||||
future seeds for the zero- and two-argument forms of seedrandom.
|
||||
|
||||
On speed - This javascript implementation of Math.random() is several
|
||||
times slower than the built-in Math.random() because it is not native
|
||||
code, but that is typically fast enough. Some details (timings on
|
||||
Chrome 25 on a 2010 vintage macbook):
|
||||
|
||||
* seeded Math.random() - avg less than 0.0002 milliseconds per call
|
||||
* seedrandom('explicit.') - avg less than 0.2 milliseconds per call
|
||||
* seedrandom('explicit.', true) - avg less than 0.2 milliseconds per call
|
||||
* seedrandom() with crypto - avg less than 0.2 milliseconds per call
|
||||
|
||||
Autoseeding without crypto is somewhat slow, about 20-30 milliseconds on
|
||||
a 2012 windows 7 1.5ghz i5 laptop, as seen on Firefox 19, IE 10, and Opera.
|
||||
Seeded rng calls themselves are fast across these browsers, with slowest
|
||||
numbers on Opera at about 0.0005 ms per seeded Math.random().
|
||||
|
||||
|
||||
LICENSE (MIT)
|
||||
-------------
|
||||
|
||||
Copyright 2015 David Bau.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
16
build/node_modules/seedrandom/bower.json
generated
vendored
Normal file
16
build/node_modules/seedrandom/bower.json
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "seedrandom",
|
||||
"description": "Seeded random number generator for Javascript.",
|
||||
"main": "seedrandom.js",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"random",
|
||||
"seed",
|
||||
"crypto"
|
||||
],
|
||||
"ignore": [],
|
||||
"devDependencies": {
|
||||
"qunit": "latest",
|
||||
"requirejs": "latest"
|
||||
}
|
||||
}
|
||||
10
build/node_modules/seedrandom/component.json
generated
vendored
Normal file
10
build/node_modules/seedrandom/component.json
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "seedrandom",
|
||||
"version": "2.4.0",
|
||||
"description": "Seeded random number generator for Javascript",
|
||||
"repository": "davidbau/seedrandom",
|
||||
"main": "seedrandom.js",
|
||||
"scripts": [ "seedrandom.js" ],
|
||||
"keywords": [ "random", "seed", "crypto" ],
|
||||
"license": "MIT"
|
||||
}
|
||||
60
build/node_modules/seedrandom/index.js
generated
vendored
Normal file
60
build/node_modules/seedrandom/index.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
// A library of seedable RNGs implemented in Javascript.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// var seedrandom = require('seedrandom');
|
||||
// var random = seedrandom(1); // or any seed.
|
||||
// var x = random(); // 0 <= x < 1. Every bit is random.
|
||||
// var x = random.quick(); // 0 <= x < 1. 32 bits of randomness.
|
||||
|
||||
// alea, a 53-bit multiply-with-carry generator by Johannes Baagøe.
|
||||
// Period: ~2^116
|
||||
// Reported to pass all BigCrush tests.
|
||||
var alea = require('./lib/alea');
|
||||
|
||||
// xor128, a pure xor-shift generator by George Marsaglia.
|
||||
// Period: 2^128-1.
|
||||
// Reported to fail: MatrixRank and LinearComp.
|
||||
var xor128 = require('./lib/xor128');
|
||||
|
||||
// xorwow, George Marsaglia's 160-bit xor-shift combined plus weyl.
|
||||
// Period: 2^192-2^32
|
||||
// Reported to fail: CollisionOver, SimpPoker, and LinearComp.
|
||||
var xorwow = require('./lib/xorwow');
|
||||
|
||||
// xorshift7, by François Panneton and Pierre L'ecuyer, takes
|
||||
// a different approach: it adds robustness by allowing more shifts
|
||||
// than Marsaglia's original three. It is a 7-shift generator
|
||||
// with 256 bits, that passes BigCrush with no systmatic failures.
|
||||
// Period 2^256-1.
|
||||
// No systematic BigCrush failures reported.
|
||||
var xorshift7 = require('./lib/xorshift7');
|
||||
|
||||
// xor4096, by Richard Brent, is a 4096-bit xor-shift with a
|
||||
// very long period that also adds a Weyl generator. It also passes
|
||||
// BigCrush with no systematic failures. Its long period may
|
||||
// be useful if you have many generators and need to avoid
|
||||
// collisions.
|
||||
// Period: 2^4128-2^32.
|
||||
// No systematic BigCrush failures reported.
|
||||
var xor4096 = require('./lib/xor4096');
|
||||
|
||||
// Tyche-i, by Samuel Neves and Filipe Araujo, is a bit-shifting random
|
||||
// number generator derived from ChaCha, a modern stream cipher.
|
||||
// https://eden.dei.uc.pt/~sneves/pubs/2011-snfa2.pdf
|
||||
// Period: ~2^127
|
||||
// No systematic BigCrush failures reported.
|
||||
var tychei = require('./lib/tychei');
|
||||
|
||||
// The original ARC4-based prng included in this library.
|
||||
// Period: ~2^1600
|
||||
var sr = require('./seedrandom');
|
||||
|
||||
sr.alea = alea;
|
||||
sr.xor128 = xor128;
|
||||
sr.xorwow = xorwow;
|
||||
sr.xorshift7 = xorshift7;
|
||||
sr.xor4096 = xor4096;
|
||||
sr.tychei = tychei;
|
||||
|
||||
module.exports = sr;
|
||||
114
build/node_modules/seedrandom/lib/alea.js
generated
vendored
Normal file
114
build/node_modules/seedrandom/lib/alea.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
// A port of an algorithm by Johannes Baagøe <baagoe@baagoe.com>, 2010
|
||||
// http://baagoe.com/en/RandomMusings/javascript/
|
||||
// https://github.com/nquinlan/better-random-numbers-for-javascript-mirror
|
||||
// Original work is under MIT license -
|
||||
|
||||
// Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
(function(global, module, define) {
|
||||
|
||||
function Alea(seed) {
|
||||
var me = this, mash = Mash();
|
||||
|
||||
me.next = function() {
|
||||
var t = 2091639 * me.s0 + me.c * 2.3283064365386963e-10; // 2^-32
|
||||
me.s0 = me.s1;
|
||||
me.s1 = me.s2;
|
||||
return me.s2 = t - (me.c = t | 0);
|
||||
};
|
||||
|
||||
// Apply the seeding algorithm from Baagoe.
|
||||
me.c = 1;
|
||||
me.s0 = mash(' ');
|
||||
me.s1 = mash(' ');
|
||||
me.s2 = mash(' ');
|
||||
me.s0 -= mash(seed);
|
||||
if (me.s0 < 0) { me.s0 += 1; }
|
||||
me.s1 -= mash(seed);
|
||||
if (me.s1 < 0) { me.s1 += 1; }
|
||||
me.s2 -= mash(seed);
|
||||
if (me.s2 < 0) { me.s2 += 1; }
|
||||
mash = null;
|
||||
}
|
||||
|
||||
function copy(f, t) {
|
||||
t.c = f.c;
|
||||
t.s0 = f.s0;
|
||||
t.s1 = f.s1;
|
||||
t.s2 = f.s2;
|
||||
return t;
|
||||
}
|
||||
|
||||
function impl(seed, opts) {
|
||||
var xg = new Alea(seed),
|
||||
state = opts && opts.state,
|
||||
prng = xg.next;
|
||||
prng.int32 = function() { return (xg.next() * 0x100000000) | 0; }
|
||||
prng.double = function() {
|
||||
return prng() + (prng() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
|
||||
};
|
||||
prng.quick = prng;
|
||||
if (state) {
|
||||
if (typeof(state) == 'object') copy(state, xg);
|
||||
prng.state = function() { return copy(xg, {}); }
|
||||
}
|
||||
return prng;
|
||||
}
|
||||
|
||||
function Mash() {
|
||||
var n = 0xefc8249d;
|
||||
|
||||
var mash = function(data) {
|
||||
data = data.toString();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
n += data.charCodeAt(i);
|
||||
var h = 0.02519603282416938 * n;
|
||||
n = h >>> 0;
|
||||
h -= n;
|
||||
h *= n;
|
||||
n = h >>> 0;
|
||||
h -= n;
|
||||
n += h * 0x100000000; // 2^32
|
||||
}
|
||||
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
|
||||
};
|
||||
|
||||
return mash;
|
||||
}
|
||||
|
||||
|
||||
if (module && module.exports) {
|
||||
module.exports = impl;
|
||||
} else if (define && define.amd) {
|
||||
define(function() { return impl; });
|
||||
} else {
|
||||
this.alea = impl;
|
||||
}
|
||||
|
||||
})(
|
||||
this,
|
||||
(typeof module) == 'object' && module, // present in node.js
|
||||
(typeof define) == 'function' && define // present with an AMD loader
|
||||
);
|
||||
|
||||
|
||||
1
build/node_modules/seedrandom/lib/alea.min.js
generated
vendored
Normal file
1
build/node_modules/seedrandom/lib/alea.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a,b,c){function d(a){var b=this,c=g();b.next=function(){var a=2091639*b.s0+2.3283064365386963e-10*b.c;return b.s0=b.s1,b.s1=b.s2,b.s2=a-(b.c=0|a)},b.c=1,b.s0=c(" "),b.s1=c(" "),b.s2=c(" "),b.s0-=c(a),b.s0<0&&(b.s0+=1),b.s1-=c(a),b.s1<0&&(b.s1+=1),b.s2-=c(a),b.s2<0&&(b.s2+=1),c=null}function e(a,b){return b.c=a.c,b.s0=a.s0,b.s1=a.s1,b.s2=a.s2,b}function f(a,b){var c=new d(a),f=b&&b.state,g=c.next;return g.int32=function(){return 4294967296*c.next()|0},g.double=function(){return g()+1.1102230246251565e-16*(2097152*g()|0)},g.quick=g,f&&("object"==typeof f&&e(f,c),g.state=function(){return e(c,{})}),g}function g(){var a=4022871197,b=function(b){b=b.toString();for(var c=0;c<b.length;c++){a+=b.charCodeAt(c);var d=.02519603282416938*a;a=d>>>0,d-=a,d*=a,a=d>>>0,d-=a,a+=4294967296*d}return 2.3283064365386963e-10*(a>>>0)};return b}b&&b.exports?b.exports=f:c&&c.amd?c(function(){return f}):this.alea=f}(this,"object"==typeof module&&module,"function"==typeof define&&define);
|
||||
11
build/node_modules/seedrandom/lib/crypto.js
generated
vendored
Normal file
11
build/node_modules/seedrandom/lib/crypto.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// mimic a subset of node's crypto API for the browser
|
||||
|
||||
function randomBytes(width) {
|
||||
var out = new Uint8Array(width);
|
||||
(global.crypto || global.msCrypto).getRandomValues(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
randomBytes: randomBytes
|
||||
}
|
||||
103
build/node_modules/seedrandom/lib/tychei.js
generated
vendored
Normal file
103
build/node_modules/seedrandom/lib/tychei.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
// A Javascript implementaion of the "Tyche-i" prng algorithm by
|
||||
// Samuel Neves and Filipe Araujo.
|
||||
// See https://eden.dei.uc.pt/~sneves/pubs/2011-snfa2.pdf
|
||||
|
||||
(function(global, module, define) {
|
||||
|
||||
function XorGen(seed) {
|
||||
var me = this, strseed = '';
|
||||
|
||||
// Set up generator function.
|
||||
me.next = function() {
|
||||
var b = me.b, c = me.c, d = me.d, a = me.a;
|
||||
b = (b << 25) ^ (b >>> 7) ^ c;
|
||||
c = (c - d) | 0;
|
||||
d = (d << 24) ^ (d >>> 8) ^ a;
|
||||
a = (a - b) | 0;
|
||||
me.b = b = (b << 20) ^ (b >>> 12) ^ c;
|
||||
me.c = c = (c - d) | 0;
|
||||
me.d = (d << 16) ^ (c >>> 16) ^ a;
|
||||
return me.a = (a - b) | 0;
|
||||
};
|
||||
|
||||
/* The following is non-inverted tyche, which has better internal
|
||||
* bit diffusion, but which is about 25% slower than tyche-i in JS.
|
||||
me.next = function() {
|
||||
var a = me.a, b = me.b, c = me.c, d = me.d;
|
||||
a = (me.a + me.b | 0) >>> 0;
|
||||
d = me.d ^ a; d = d << 16 ^ d >>> 16;
|
||||
c = me.c + d | 0;
|
||||
b = me.b ^ c; b = b << 12 ^ d >>> 20;
|
||||
me.a = a = a + b | 0;
|
||||
d = d ^ a; me.d = d = d << 8 ^ d >>> 24;
|
||||
me.c = c = c + d | 0;
|
||||
b = b ^ c;
|
||||
return me.b = (b << 7 ^ b >>> 25);
|
||||
}
|
||||
*/
|
||||
|
||||
me.a = 0;
|
||||
me.b = 0;
|
||||
me.c = 2654435769 | 0;
|
||||
me.d = 1367130551;
|
||||
|
||||
if (seed === Math.floor(seed)) {
|
||||
// Integer seed.
|
||||
me.a = (seed / 0x100000000) | 0;
|
||||
me.b = seed | 0;
|
||||
} else {
|
||||
// String seed.
|
||||
strseed += seed;
|
||||
}
|
||||
|
||||
// Mix in string seed, then discard an initial batch of 64 values.
|
||||
for (var k = 0; k < strseed.length + 20; k++) {
|
||||
me.b ^= strseed.charCodeAt(k) | 0;
|
||||
me.next();
|
||||
}
|
||||
}
|
||||
|
||||
function copy(f, t) {
|
||||
t.a = f.a;
|
||||
t.b = f.b;
|
||||
t.c = f.c;
|
||||
t.d = f.d;
|
||||
return t;
|
||||
};
|
||||
|
||||
function impl(seed, opts) {
|
||||
var xg = new XorGen(seed),
|
||||
state = opts && opts.state,
|
||||
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
||||
prng.double = function() {
|
||||
do {
|
||||
var top = xg.next() >>> 11,
|
||||
bot = (xg.next() >>> 0) / 0x100000000,
|
||||
result = (top + bot) / (1 << 21);
|
||||
} while (result === 0);
|
||||
return result;
|
||||
};
|
||||
prng.int32 = xg.next;
|
||||
prng.quick = prng;
|
||||
if (state) {
|
||||
if (typeof(state) == 'object') copy(state, xg);
|
||||
prng.state = function() { return copy(xg, {}); }
|
||||
}
|
||||
return prng;
|
||||
}
|
||||
|
||||
if (module && module.exports) {
|
||||
module.exports = impl;
|
||||
} else if (define && define.amd) {
|
||||
define(function() { return impl; });
|
||||
} else {
|
||||
this.tychei = impl;
|
||||
}
|
||||
|
||||
})(
|
||||
this,
|
||||
(typeof module) == 'object' && module, // present in node.js
|
||||
(typeof define) == 'function' && define // present with an AMD loader
|
||||
);
|
||||
|
||||
|
||||
1
build/node_modules/seedrandom/lib/tychei.min.js
generated
vendored
Normal file
1
build/node_modules/seedrandom/lib/tychei.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a,b,c){function d(a){var b=this,c="";b.next=function(){var a=b.b,c=b.c,d=b.d,e=b.a;return a=a<<25^a>>>7^c,c=c-d|0,d=d<<24^d>>>8^e,e=e-a|0,b.b=a=a<<20^a>>>12^c,b.c=c=c-d|0,b.d=d<<16^c>>>16^e,b.a=e-a|0},b.a=0,b.b=0,b.c=-1640531527,b.d=1367130551,a===Math.floor(a)?(b.a=a/4294967296|0,b.b=0|a):c+=a;for(var d=0;d<c.length+20;d++)b.b^=0|c.charCodeAt(d),b.next()}function e(a,b){return b.a=a.a,b.b=a.b,b.c=a.c,b.d=a.d,b}function f(a,b){var c=new d(a),f=b&&b.state,g=function(){return(c.next()>>>0)/4294967296};return g.double=function(){do var a=c.next()>>>11,b=(c.next()>>>0)/4294967296,d=(a+b)/(1<<21);while(0===d);return d},g.int32=c.next,g.quick=g,f&&("object"==typeof f&&e(f,c),g.state=function(){return e(c,{})}),g}b&&b.exports?b.exports=f:c&&c.amd?c(function(){return f}):this.tychei=f}(this,"object"==typeof module&&module,"function"==typeof define&&define);
|
||||
81
build/node_modules/seedrandom/lib/xor128.js
generated
vendored
Normal file
81
build/node_modules/seedrandom/lib/xor128.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
// A Javascript implementaion of the "xor128" prng algorithm by
|
||||
// George Marsaglia. See http://www.jstatsoft.org/v08/i14/paper
|
||||
|
||||
(function(global, module, define) {
|
||||
|
||||
function XorGen(seed) {
|
||||
var me = this, strseed = '';
|
||||
|
||||
me.x = 0;
|
||||
me.y = 0;
|
||||
me.z = 0;
|
||||
me.w = 0;
|
||||
|
||||
// Set up generator function.
|
||||
me.next = function() {
|
||||
var t = me.x ^ (me.x << 11);
|
||||
me.x = me.y;
|
||||
me.y = me.z;
|
||||
me.z = me.w;
|
||||
return me.w ^= (me.w >>> 19) ^ t ^ (t >>> 8);
|
||||
};
|
||||
|
||||
if (seed === (seed | 0)) {
|
||||
// Integer seed.
|
||||
me.x = seed;
|
||||
} else {
|
||||
// String seed.
|
||||
strseed += seed;
|
||||
}
|
||||
|
||||
// Mix in string seed, then discard an initial batch of 64 values.
|
||||
for (var k = 0; k < strseed.length + 64; k++) {
|
||||
me.x ^= strseed.charCodeAt(k) | 0;
|
||||
me.next();
|
||||
}
|
||||
}
|
||||
|
||||
function copy(f, t) {
|
||||
t.x = f.x;
|
||||
t.y = f.y;
|
||||
t.z = f.z;
|
||||
t.w = f.w;
|
||||
return t;
|
||||
}
|
||||
|
||||
function impl(seed, opts) {
|
||||
var xg = new XorGen(seed),
|
||||
state = opts && opts.state,
|
||||
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
||||
prng.double = function() {
|
||||
do {
|
||||
var top = xg.next() >>> 11,
|
||||
bot = (xg.next() >>> 0) / 0x100000000,
|
||||
result = (top + bot) / (1 << 21);
|
||||
} while (result === 0);
|
||||
return result;
|
||||
};
|
||||
prng.int32 = xg.next;
|
||||
prng.quick = prng;
|
||||
if (state) {
|
||||
if (typeof(state) == 'object') copy(state, xg);
|
||||
prng.state = function() { return copy(xg, {}); }
|
||||
}
|
||||
return prng;
|
||||
}
|
||||
|
||||
if (module && module.exports) {
|
||||
module.exports = impl;
|
||||
} else if (define && define.amd) {
|
||||
define(function() { return impl; });
|
||||
} else {
|
||||
this.xor128 = impl;
|
||||
}
|
||||
|
||||
})(
|
||||
this,
|
||||
(typeof module) == 'object' && module, // present in node.js
|
||||
(typeof define) == 'function' && define // present with an AMD loader
|
||||
);
|
||||
|
||||
|
||||
1
build/node_modules/seedrandom/lib/xor128.min.js
generated
vendored
Normal file
1
build/node_modules/seedrandom/lib/xor128.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a,b,c){function d(a){var b=this,c="";b.x=0,b.y=0,b.z=0,b.w=0,b.next=function(){var a=b.x^b.x<<11;return b.x=b.y,b.y=b.z,b.z=b.w,b.w^=b.w>>>19^a^a>>>8},a===(0|a)?b.x=a:c+=a;for(var d=0;d<c.length+64;d++)b.x^=0|c.charCodeAt(d),b.next()}function e(a,b){return b.x=a.x,b.y=a.y,b.z=a.z,b.w=a.w,b}function f(a,b){var c=new d(a),f=b&&b.state,g=function(){return(c.next()>>>0)/4294967296};return g.double=function(){do var a=c.next()>>>11,b=(c.next()>>>0)/4294967296,d=(a+b)/(1<<21);while(0===d);return d},g.int32=c.next,g.quick=g,f&&("object"==typeof f&&e(f,c),g.state=function(){return e(c,{})}),g}b&&b.exports?b.exports=f:c&&c.amd?c(function(){return f}):this.xor128=f}(this,"object"==typeof module&&module,"function"==typeof define&&define);
|
||||
146
build/node_modules/seedrandom/lib/xor4096.js
generated
vendored
Normal file
146
build/node_modules/seedrandom/lib/xor4096.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
// A Javascript implementaion of Richard Brent's Xorgens xor4096 algorithm.
|
||||
//
|
||||
// This fast non-cryptographic random number generator is designed for
|
||||
// use in Monte-Carlo algorithms. It combines a long-period xorshift
|
||||
// generator with a Weyl generator, and it passes all common batteries
|
||||
// of stasticial tests for randomness while consuming only a few nanoseconds
|
||||
// for each prng generated. For background on the generator, see Brent's
|
||||
// paper: "Some long-period random number generators using shifts and xors."
|
||||
// http://arxiv.org/pdf/1004.3115v1.pdf
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// var xor4096 = require('xor4096');
|
||||
// random = xor4096(1); // Seed with int32 or string.
|
||||
// assert.equal(random(), 0.1520436450538547); // (0, 1) range, 53 bits.
|
||||
// assert.equal(random.int32(), 1806534897); // signed int32, 32 bits.
|
||||
//
|
||||
// For nonzero numeric keys, this impelementation provides a sequence
|
||||
// identical to that by Brent's xorgens 3 implementaion in C. This
|
||||
// implementation also provides for initalizing the generator with
|
||||
// string seeds, or for saving and restoring the state of the generator.
|
||||
//
|
||||
// On Chrome, this prng benchmarks about 2.1 times slower than
|
||||
// Javascript's built-in Math.random().
|
||||
|
||||
(function(global, module, define) {
|
||||
|
||||
function XorGen(seed) {
|
||||
var me = this;
|
||||
|
||||
// Set up generator function.
|
||||
me.next = function() {
|
||||
var w = me.w,
|
||||
X = me.X, i = me.i, t, v;
|
||||
// Update Weyl generator.
|
||||
me.w = w = (w + 0x61c88647) | 0;
|
||||
// Update xor generator.
|
||||
v = X[(i + 34) & 127];
|
||||
t = X[i = ((i + 1) & 127)];
|
||||
v ^= v << 13;
|
||||
t ^= t << 17;
|
||||
v ^= v >>> 15;
|
||||
t ^= t >>> 12;
|
||||
// Update Xor generator array state.
|
||||
v = X[i] = v ^ t;
|
||||
me.i = i;
|
||||
// Result is the combination.
|
||||
return (v + (w ^ (w >>> 16))) | 0;
|
||||
};
|
||||
|
||||
function init(me, seed) {
|
||||
var t, v, i, j, w, X = [], limit = 128;
|
||||
if (seed === (seed | 0)) {
|
||||
// Numeric seeds initialize v, which is used to generates X.
|
||||
v = seed;
|
||||
seed = null;
|
||||
} else {
|
||||
// String seeds are mixed into v and X one character at a time.
|
||||
seed = seed + '\0';
|
||||
v = 0;
|
||||
limit = Math.max(limit, seed.length);
|
||||
}
|
||||
// Initialize circular array and weyl value.
|
||||
for (i = 0, j = -32; j < limit; ++j) {
|
||||
// Put the unicode characters into the array, and shuffle them.
|
||||
if (seed) v ^= seed.charCodeAt((j + 32) % seed.length);
|
||||
// After 32 shuffles, take v as the starting w value.
|
||||
if (j === 0) w = v;
|
||||
v ^= v << 10;
|
||||
v ^= v >>> 15;
|
||||
v ^= v << 4;
|
||||
v ^= v >>> 13;
|
||||
if (j >= 0) {
|
||||
w = (w + 0x61c88647) | 0; // Weyl.
|
||||
t = (X[j & 127] ^= (v + w)); // Combine xor and weyl to init array.
|
||||
i = (0 == t) ? i + 1 : 0; // Count zeroes.
|
||||
}
|
||||
}
|
||||
// We have detected all zeroes; make the key nonzero.
|
||||
if (i >= 128) {
|
||||
X[(seed && seed.length || 0) & 127] = -1;
|
||||
}
|
||||
// Run the generator 512 times to further mix the state before using it.
|
||||
// Factoring this as a function slows the main generator, so it is just
|
||||
// unrolled here. The weyl generator is not advanced while warming up.
|
||||
i = 127;
|
||||
for (j = 4 * 128; j > 0; --j) {
|
||||
v = X[(i + 34) & 127];
|
||||
t = X[i = ((i + 1) & 127)];
|
||||
v ^= v << 13;
|
||||
t ^= t << 17;
|
||||
v ^= v >>> 15;
|
||||
t ^= t >>> 12;
|
||||
X[i] = v ^ t;
|
||||
}
|
||||
// Storing state as object members is faster than using closure variables.
|
||||
me.w = w;
|
||||
me.X = X;
|
||||
me.i = i;
|
||||
}
|
||||
|
||||
init(me, seed);
|
||||
}
|
||||
|
||||
function copy(f, t) {
|
||||
t.i = f.i;
|
||||
t.w = f.w;
|
||||
t.X = f.X.slice();
|
||||
return t;
|
||||
};
|
||||
|
||||
function impl(seed, opts) {
|
||||
if (seed == null) seed = +(new Date);
|
||||
var xg = new XorGen(seed),
|
||||
state = opts && opts.state,
|
||||
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
||||
prng.double = function() {
|
||||
do {
|
||||
var top = xg.next() >>> 11,
|
||||
bot = (xg.next() >>> 0) / 0x100000000,
|
||||
result = (top + bot) / (1 << 21);
|
||||
} while (result === 0);
|
||||
return result;
|
||||
};
|
||||
prng.int32 = xg.next;
|
||||
prng.quick = prng;
|
||||
if (state) {
|
||||
if (state.X) copy(state, xg);
|
||||
prng.state = function() { return copy(xg, {}); }
|
||||
}
|
||||
return prng;
|
||||
}
|
||||
|
||||
if (module && module.exports) {
|
||||
module.exports = impl;
|
||||
} else if (define && define.amd) {
|
||||
define(function() { return impl; });
|
||||
} else {
|
||||
this.xor4096 = impl;
|
||||
}
|
||||
|
||||
})(
|
||||
this, // window object or global
|
||||
(typeof module) == 'object' && module, // present in node.js
|
||||
(typeof define) == 'function' && define // present with an AMD loader
|
||||
);
|
||||
1
build/node_modules/seedrandom/lib/xor4096.min.js
generated
vendored
Normal file
1
build/node_modules/seedrandom/lib/xor4096.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a,b,c){function d(a){function b(a,b){var c,d,e,f,g,h=[],i=128;for(b===(0|b)?(d=b,b=null):(b+="\0",d=0,i=Math.max(i,b.length)),e=0,f=-32;f<i;++f)b&&(d^=b.charCodeAt((f+32)%b.length)),0===f&&(g=d),d^=d<<10,d^=d>>>15,d^=d<<4,d^=d>>>13,f>=0&&(g=g+1640531527|0,c=h[127&f]^=d+g,e=0==c?e+1:0);for(e>=128&&(h[127&(b&&b.length||0)]=-1),e=127,f=512;f>0;--f)d=h[e+34&127],c=h[e=e+1&127],d^=d<<13,c^=c<<17,d^=d>>>15,c^=c>>>12,h[e]=d^c;a.w=g,a.X=h,a.i=e}var c=this;c.next=function(){var a,b,d=c.w,e=c.X,f=c.i;return c.w=d=d+1640531527|0,b=e[f+34&127],a=e[f=f+1&127],b^=b<<13,a^=a<<17,b^=b>>>15,a^=a>>>12,b=e[f]=b^a,c.i=f,b+(d^d>>>16)|0},b(c,a)}function e(a,b){return b.i=a.i,b.w=a.w,b.X=a.X.slice(),b}function f(a,b){null==a&&(a=+new Date);var c=new d(a),f=b&&b.state,g=function(){return(c.next()>>>0)/4294967296};return g.double=function(){do var a=c.next()>>>11,b=(c.next()>>>0)/4294967296,d=(a+b)/(1<<21);while(0===d);return d},g.int32=c.next,g.quick=g,f&&(f.X&&e(f,c),g.state=function(){return e(c,{})}),g}b&&b.exports?b.exports=f:c&&c.amd?c(function(){return f}):this.xor4096=f}(this,"object"==typeof module&&module,"function"==typeof define&&define);
|
||||
97
build/node_modules/seedrandom/lib/xorshift7.js
generated
vendored
Normal file
97
build/node_modules/seedrandom/lib/xorshift7.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
// A Javascript implementaion of the "xorshift7" algorithm by
|
||||
// François Panneton and Pierre L'ecuyer:
|
||||
// "On the Xorgshift Random Number Generators"
|
||||
// http://saluc.engr.uconn.edu/refs/crypto/rng/panneton05onthexorshift.pdf
|
||||
|
||||
(function(global, module, define) {
|
||||
|
||||
function XorGen(seed) {
|
||||
var me = this;
|
||||
|
||||
// Set up generator function.
|
||||
me.next = function() {
|
||||
// Update xor generator.
|
||||
var X = me.x, i = me.i, t, v, w;
|
||||
t = X[i]; t ^= (t >>> 7); v = t ^ (t << 24);
|
||||
t = X[(i + 1) & 7]; v ^= t ^ (t >>> 10);
|
||||
t = X[(i + 3) & 7]; v ^= t ^ (t >>> 3);
|
||||
t = X[(i + 4) & 7]; v ^= t ^ (t << 7);
|
||||
t = X[(i + 7) & 7]; t = t ^ (t << 13); v ^= t ^ (t << 9);
|
||||
X[i] = v;
|
||||
me.i = (i + 1) & 7;
|
||||
return v;
|
||||
};
|
||||
|
||||
function init(me, seed) {
|
||||
var j, w, X = [];
|
||||
|
||||
if (seed === (seed | 0)) {
|
||||
// Seed state array using a 32-bit integer.
|
||||
w = X[0] = seed;
|
||||
} else {
|
||||
// Seed state using a string.
|
||||
seed = '' + seed;
|
||||
for (j = 0; j < seed.length; ++j) {
|
||||
X[j & 7] = (X[j & 7] << 15) ^
|
||||
(seed.charCodeAt(j) + X[(j + 1) & 7] << 13);
|
||||
}
|
||||
}
|
||||
// Enforce an array length of 8, not all zeroes.
|
||||
while (X.length < 8) X.push(0);
|
||||
for (j = 0; j < 8 && X[j] === 0; ++j);
|
||||
if (j == 8) w = X[7] = -1; else w = X[j];
|
||||
|
||||
me.x = X;
|
||||
me.i = 0;
|
||||
|
||||
// Discard an initial 256 values.
|
||||
for (j = 256; j > 0; --j) {
|
||||
me.next();
|
||||
}
|
||||
}
|
||||
|
||||
init(me, seed);
|
||||
}
|
||||
|
||||
function copy(f, t) {
|
||||
t.x = f.x.slice();
|
||||
t.i = f.i;
|
||||
return t;
|
||||
}
|
||||
|
||||
function impl(seed, opts) {
|
||||
if (seed == null) seed = +(new Date);
|
||||
var xg = new XorGen(seed),
|
||||
state = opts && opts.state,
|
||||
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
||||
prng.double = function() {
|
||||
do {
|
||||
var top = xg.next() >>> 11,
|
||||
bot = (xg.next() >>> 0) / 0x100000000,
|
||||
result = (top + bot) / (1 << 21);
|
||||
} while (result === 0);
|
||||
return result;
|
||||
};
|
||||
prng.int32 = xg.next;
|
||||
prng.quick = prng;
|
||||
if (state) {
|
||||
if (state.x) copy(state, xg);
|
||||
prng.state = function() { return copy(xg, {}); }
|
||||
}
|
||||
return prng;
|
||||
}
|
||||
|
||||
if (module && module.exports) {
|
||||
module.exports = impl;
|
||||
} else if (define && define.amd) {
|
||||
define(function() { return impl; });
|
||||
} else {
|
||||
this.xorshift7 = impl;
|
||||
}
|
||||
|
||||
})(
|
||||
this,
|
||||
(typeof module) == 'object' && module, // present in node.js
|
||||
(typeof define) == 'function' && define // present with an AMD loader
|
||||
);
|
||||
|
||||
1
build/node_modules/seedrandom/lib/xorshift7.min.js
generated
vendored
Normal file
1
build/node_modules/seedrandom/lib/xorshift7.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a,b,c){function d(a){function b(a,b){var c,d,e=[];if(b===(0|b))d=e[0]=b;else for(b=""+b,c=0;c<b.length;++c)e[7&c]=e[7&c]<<15^b.charCodeAt(c)+e[c+1&7]<<13;for(;e.length<8;)e.push(0);for(c=0;c<8&&0===e[c];++c);for(d=8==c?e[7]=-1:e[c],a.x=e,a.i=0,c=256;c>0;--c)a.next()}var c=this;c.next=function(){var a,b,d=c.x,e=c.i;return a=d[e],a^=a>>>7,b=a^a<<24,a=d[e+1&7],b^=a^a>>>10,a=d[e+3&7],b^=a^a>>>3,a=d[e+4&7],b^=a^a<<7,a=d[e+7&7],a^=a<<13,b^=a^a<<9,d[e]=b,c.i=e+1&7,b},b(c,a)}function e(a,b){return b.x=a.x.slice(),b.i=a.i,b}function f(a,b){null==a&&(a=+new Date);var c=new d(a),f=b&&b.state,g=function(){return(c.next()>>>0)/4294967296};return g.double=function(){do var a=c.next()>>>11,b=(c.next()>>>0)/4294967296,d=(a+b)/(1<<21);while(0===d);return d},g.int32=c.next,g.quick=g,f&&(f.x&&e(f,c),g.state=function(){return e(c,{})}),g}b&&b.exports?b.exports=f:c&&c.amd?c(function(){return f}):this.xorshift7=f}(this,"object"==typeof module&&module,"function"==typeof define&&define);
|
||||
86
build/node_modules/seedrandom/lib/xorwow.js
generated
vendored
Normal file
86
build/node_modules/seedrandom/lib/xorwow.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
// A Javascript implementaion of the "xorwow" prng algorithm by
|
||||
// George Marsaglia. See http://www.jstatsoft.org/v08/i14/paper
|
||||
|
||||
(function(global, module, define) {
|
||||
|
||||
function XorGen(seed) {
|
||||
var me = this, strseed = '';
|
||||
|
||||
// Set up generator function.
|
||||
me.next = function() {
|
||||
var t = (me.x ^ (me.x >>> 2));
|
||||
me.x = me.y; me.y = me.z; me.z = me.w; me.w = me.v;
|
||||
return (me.d = (me.d + 362437 | 0)) +
|
||||
(me.v = (me.v ^ (me.v << 4)) ^ (t ^ (t << 1))) | 0;
|
||||
};
|
||||
|
||||
me.x = 0;
|
||||
me.y = 0;
|
||||
me.z = 0;
|
||||
me.w = 0;
|
||||
me.v = 0;
|
||||
|
||||
if (seed === (seed | 0)) {
|
||||
// Integer seed.
|
||||
me.x = seed;
|
||||
} else {
|
||||
// String seed.
|
||||
strseed += seed;
|
||||
}
|
||||
|
||||
// Mix in string seed, then discard an initial batch of 64 values.
|
||||
for (var k = 0; k < strseed.length + 64; k++) {
|
||||
me.x ^= strseed.charCodeAt(k) | 0;
|
||||
if (k == strseed.length) {
|
||||
me.d = me.x << 10 ^ me.x >>> 4;
|
||||
}
|
||||
me.next();
|
||||
}
|
||||
}
|
||||
|
||||
function copy(f, t) {
|
||||
t.x = f.x;
|
||||
t.y = f.y;
|
||||
t.z = f.z;
|
||||
t.w = f.w;
|
||||
t.v = f.v;
|
||||
t.d = f.d;
|
||||
return t;
|
||||
}
|
||||
|
||||
function impl(seed, opts) {
|
||||
var xg = new XorGen(seed),
|
||||
state = opts && opts.state,
|
||||
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
||||
prng.double = function() {
|
||||
do {
|
||||
var top = xg.next() >>> 11,
|
||||
bot = (xg.next() >>> 0) / 0x100000000,
|
||||
result = (top + bot) / (1 << 21);
|
||||
} while (result === 0);
|
||||
return result;
|
||||
};
|
||||
prng.int32 = xg.next;
|
||||
prng.quick = prng;
|
||||
if (state) {
|
||||
if (typeof(state) == 'object') copy(state, xg);
|
||||
prng.state = function() { return copy(xg, {}); }
|
||||
}
|
||||
return prng;
|
||||
}
|
||||
|
||||
if (module && module.exports) {
|
||||
module.exports = impl;
|
||||
} else if (define && define.amd) {
|
||||
define(function() { return impl; });
|
||||
} else {
|
||||
this.xorwow = impl;
|
||||
}
|
||||
|
||||
})(
|
||||
this,
|
||||
(typeof module) == 'object' && module, // present in node.js
|
||||
(typeof define) == 'function' && define // present with an AMD loader
|
||||
);
|
||||
|
||||
|
||||
1
build/node_modules/seedrandom/lib/xorwow.min.js
generated
vendored
Normal file
1
build/node_modules/seedrandom/lib/xorwow.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a,b,c){function d(a){var b=this,c="";b.next=function(){var a=b.x^b.x>>>2;return b.x=b.y,b.y=b.z,b.z=b.w,b.w=b.v,(b.d=b.d+362437|0)+(b.v=b.v^b.v<<4^(a^a<<1))|0},b.x=0,b.y=0,b.z=0,b.w=0,b.v=0,a===(0|a)?b.x=a:c+=a;for(var d=0;d<c.length+64;d++)b.x^=0|c.charCodeAt(d),d==c.length&&(b.d=b.x<<10^b.x>>>4),b.next()}function e(a,b){return b.x=a.x,b.y=a.y,b.z=a.z,b.w=a.w,b.v=a.v,b.d=a.d,b}function f(a,b){var c=new d(a),f=b&&b.state,g=function(){return(c.next()>>>0)/4294967296};return g.double=function(){do var a=c.next()>>>11,b=(c.next()>>>0)/4294967296,d=(a+b)/(1<<21);while(0===d);return d},g.int32=c.next,g.quick=g,f&&("object"==typeof f&&e(f,c),g.state=function(){return e(c,{})}),g}b&&b.exports?b.exports=f:c&&c.amd?c(function(){return f}):this.xorwow=f}(this,"object"==typeof module&&module,"function"==typeof define&&define);
|
||||
82
build/node_modules/seedrandom/package.json
generated
vendored
Normal file
82
build/node_modules/seedrandom/package.json
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"_from": "seedrandom@^2.4.2",
|
||||
"_id": "seedrandom@2.4.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-JDhQTa0zkXMUv/GKxNeU8W1qrsw=",
|
||||
"_location": "/seedrandom",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "seedrandom@^2.4.2",
|
||||
"name": "seedrandom",
|
||||
"escapedName": "seedrandom",
|
||||
"rawSpec": "^2.4.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.4.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/prepack"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.3.tgz",
|
||||
"_shasum": "2438504dad33917314bff18ac4d794f16d6aaecc",
|
||||
"_spec": "seedrandom@^2.4.2",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/prepack",
|
||||
"author": {
|
||||
"name": "David Bau"
|
||||
},
|
||||
"browser": {
|
||||
"crypto": false
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/davidbau/seedrandom/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"config": {
|
||||
"blanket": {
|
||||
"pattern": [
|
||||
"seedrandom.js",
|
||||
"lib/alea.js",
|
||||
"lib/xor128.js",
|
||||
"lib/xorwow.js",
|
||||
"lib/xorshift7.js",
|
||||
"lib/tychei.js",
|
||||
"lib/xor4096.js"
|
||||
]
|
||||
}
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Seeded random number generator for Javascript.",
|
||||
"devDependencies": {
|
||||
"blanket": "latest",
|
||||
"grunt": "latest",
|
||||
"grunt-bowercopy": "latest",
|
||||
"grunt-browserify": "latest",
|
||||
"grunt-cli": "latest",
|
||||
"grunt-contrib-connect": "latest",
|
||||
"grunt-contrib-qunit": "latest",
|
||||
"grunt-contrib-uglify": "latest",
|
||||
"grunt-mocha-cov": "latest",
|
||||
"grunt-release": "latest",
|
||||
"phantomjs-prebuilt": "latest",
|
||||
"proxyquire": "latest",
|
||||
"requirejs": "latest"
|
||||
},
|
||||
"homepage": "http://davidbau.com/archives/2010/01/30/random_seeds_coded_hints_and_quintillions.html",
|
||||
"keywords": [
|
||||
"seed",
|
||||
"random",
|
||||
"crypto"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "seedrandom",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/davidbau/seedrandom.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt travis"
|
||||
},
|
||||
"version": "2.4.3"
|
||||
}
|
||||
247
build/node_modules/seedrandom/seedrandom.js
generated
vendored
Normal file
247
build/node_modules/seedrandom/seedrandom.js
generated
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
Copyright 2014 David Bau.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
(function (pool, math) {
|
||||
//
|
||||
// The following constants are related to IEEE 754 limits.
|
||||
//
|
||||
var global = this,
|
||||
width = 256, // each RC4 output is 0 <= x < 256
|
||||
chunks = 6, // at least six RC4 outputs for each double
|
||||
digits = 52, // there are 52 significant digits in a double
|
||||
rngname = 'random', // rngname: name for Math.random and Math.seedrandom
|
||||
startdenom = math.pow(width, chunks),
|
||||
significance = math.pow(2, digits),
|
||||
overflow = significance * 2,
|
||||
mask = width - 1,
|
||||
nodecrypto; // node.js crypto module, initialized at the bottom.
|
||||
|
||||
//
|
||||
// seedrandom()
|
||||
// This is the seedrandom function described above.
|
||||
//
|
||||
function seedrandom(seed, options, callback) {
|
||||
var key = [];
|
||||
options = (options == true) ? { entropy: true } : (options || {});
|
||||
|
||||
// Flatten the seed string or build one from local entropy if needed.
|
||||
var shortseed = mixkey(flatten(
|
||||
options.entropy ? [seed, tostring(pool)] :
|
||||
(seed == null) ? autoseed() : seed, 3), key);
|
||||
|
||||
// Use the seed to initialize an ARC4 generator.
|
||||
var arc4 = new ARC4(key);
|
||||
|
||||
// This function returns a random double in [0, 1) that contains
|
||||
// randomness in every bit of the mantissa of the IEEE 754 value.
|
||||
var prng = function() {
|
||||
var n = arc4.g(chunks), // Start with a numerator n < 2 ^ 48
|
||||
d = startdenom, // and denominator d = 2 ^ 48.
|
||||
x = 0; // and no 'extra last byte'.
|
||||
while (n < significance) { // Fill up all significant digits by
|
||||
n = (n + x) * width; // shifting numerator and
|
||||
d *= width; // denominator and generating a
|
||||
x = arc4.g(1); // new least-significant-byte.
|
||||
}
|
||||
while (n >= overflow) { // To avoid rounding up, before adding
|
||||
n /= 2; // last byte, shift everything
|
||||
d /= 2; // right using integer math until
|
||||
x >>>= 1; // we have exactly the desired bits.
|
||||
}
|
||||
return (n + x) / d; // Form the number within [0, 1).
|
||||
};
|
||||
|
||||
prng.int32 = function() { return arc4.g(4) | 0; }
|
||||
prng.quick = function() { return arc4.g(4) / 0x100000000; }
|
||||
prng.double = prng;
|
||||
|
||||
// Mix the randomness into accumulated entropy.
|
||||
mixkey(tostring(arc4.S), pool);
|
||||
|
||||
// Calling convention: what to return as a function of prng, seed, is_math.
|
||||
return (options.pass || callback ||
|
||||
function(prng, seed, is_math_call, state) {
|
||||
if (state) {
|
||||
// Load the arc4 state from the given state if it has an S array.
|
||||
if (state.S) { copy(state, arc4); }
|
||||
// Only provide the .state method if requested via options.state.
|
||||
prng.state = function() { return copy(arc4, {}); }
|
||||
}
|
||||
|
||||
// If called as a method of Math (Math.seedrandom()), mutate
|
||||
// Math.random because that is how seedrandom.js has worked since v1.0.
|
||||
if (is_math_call) { math[rngname] = prng; return seed; }
|
||||
|
||||
// Otherwise, it is a newer calling convention, so return the
|
||||
// prng directly.
|
||||
else return prng;
|
||||
})(
|
||||
prng,
|
||||
shortseed,
|
||||
'global' in options ? options.global : (this == math),
|
||||
options.state);
|
||||
}
|
||||
math['seed' + rngname] = seedrandom;
|
||||
|
||||
//
|
||||
// ARC4
|
||||
//
|
||||
// An ARC4 implementation. The constructor takes a key in the form of
|
||||
// an array of at most (width) integers that should be 0 <= x < (width).
|
||||
//
|
||||
// The g(count) method returns a pseudorandom integer that concatenates
|
||||
// the next (count) outputs from ARC4. Its return value is a number x
|
||||
// that is in the range 0 <= x < (width ^ count).
|
||||
//
|
||||
function ARC4(key) {
|
||||
var t, keylen = key.length,
|
||||
me = this, i = 0, j = me.i = me.j = 0, s = me.S = [];
|
||||
|
||||
// The empty key [] is treated as [0].
|
||||
if (!keylen) { key = [keylen++]; }
|
||||
|
||||
// Set up S using the standard key scheduling algorithm.
|
||||
while (i < width) {
|
||||
s[i] = i++;
|
||||
}
|
||||
for (i = 0; i < width; i++) {
|
||||
s[i] = s[j = mask & (j + key[i % keylen] + (t = s[i]))];
|
||||
s[j] = t;
|
||||
}
|
||||
|
||||
// The "g" method returns the next (count) outputs as one number.
|
||||
(me.g = function(count) {
|
||||
// Using instance members instead of closure state nearly doubles speed.
|
||||
var t, r = 0,
|
||||
i = me.i, j = me.j, s = me.S;
|
||||
while (count--) {
|
||||
t = s[i = mask & (i + 1)];
|
||||
r = r * width + s[mask & ((s[i] = s[j = mask & (j + t)]) + (s[j] = t))];
|
||||
}
|
||||
me.i = i; me.j = j;
|
||||
return r;
|
||||
// For robust unpredictability, the function call below automatically
|
||||
// discards an initial batch of values. This is called RC4-drop[256].
|
||||
// See http://google.com/search?q=rsa+fluhrer+response&btnI
|
||||
})(width);
|
||||
}
|
||||
|
||||
//
|
||||
// copy()
|
||||
// Copies internal state of ARC4 to or from a plain object.
|
||||
//
|
||||
function copy(f, t) {
|
||||
t.i = f.i;
|
||||
t.j = f.j;
|
||||
t.S = f.S.slice();
|
||||
return t;
|
||||
};
|
||||
|
||||
//
|
||||
// flatten()
|
||||
// Converts an object tree to nested arrays of strings.
|
||||
//
|
||||
function flatten(obj, depth) {
|
||||
var result = [], typ = (typeof obj), prop;
|
||||
if (depth && typ == 'object') {
|
||||
for (prop in obj) {
|
||||
try { result.push(flatten(obj[prop], depth - 1)); } catch (e) {}
|
||||
}
|
||||
}
|
||||
return (result.length ? result : typ == 'string' ? obj : obj + '\0');
|
||||
}
|
||||
|
||||
//
|
||||
// mixkey()
|
||||
// Mixes a string seed into a key that is an array of integers, and
|
||||
// returns a shortened string seed that is equivalent to the result key.
|
||||
//
|
||||
function mixkey(seed, key) {
|
||||
var stringseed = seed + '', smear, j = 0;
|
||||
while (j < stringseed.length) {
|
||||
key[mask & j] =
|
||||
mask & ((smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++));
|
||||
}
|
||||
return tostring(key);
|
||||
}
|
||||
|
||||
//
|
||||
// autoseed()
|
||||
// Returns an object for autoseeding, using window.crypto and Node crypto
|
||||
// module if available.
|
||||
//
|
||||
function autoseed() {
|
||||
try {
|
||||
var out;
|
||||
if (nodecrypto && (out = nodecrypto.randomBytes)) {
|
||||
// The use of 'out' to remember randomBytes makes tight minified code.
|
||||
out = out(width);
|
||||
} else {
|
||||
out = new Uint8Array(width);
|
||||
(global.crypto || global.msCrypto).getRandomValues(out);
|
||||
}
|
||||
return tostring(out);
|
||||
} catch (e) {
|
||||
var browser = global.navigator,
|
||||
plugins = browser && browser.plugins;
|
||||
return [+new Date, global, plugins, global.screen, tostring(pool)];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// tostring()
|
||||
// Converts an array of charcodes to a string
|
||||
//
|
||||
function tostring(a) {
|
||||
return String.fromCharCode.apply(0, a);
|
||||
}
|
||||
|
||||
//
|
||||
// When seedrandom.js is loaded, we immediately mix a few bits
|
||||
// from the built-in RNG into the entropy pool. Because we do
|
||||
// not want to interfere with deterministic PRNG state later,
|
||||
// seedrandom will not call math.random on its own again after
|
||||
// initialization.
|
||||
//
|
||||
mixkey(math.random(), pool);
|
||||
|
||||
//
|
||||
// Nodejs and AMD support: export the implementation as a module using
|
||||
// either convention.
|
||||
//
|
||||
if ((typeof module) == 'object' && module.exports) {
|
||||
module.exports = seedrandom;
|
||||
// When in node.js, try using crypto package for autoseeding.
|
||||
try {
|
||||
nodecrypto = require('crypto');
|
||||
} catch (ex) {}
|
||||
} else if ((typeof define) == 'function' && define.amd) {
|
||||
define(function() { return seedrandom; });
|
||||
}
|
||||
|
||||
// End anonymous scope, and pass initial values.
|
||||
})(
|
||||
[], // pool: entropy pool starts empty
|
||||
Math // math: package containing random, pow, and seedrandom
|
||||
);
|
||||
1
build/node_modules/seedrandom/seedrandom.min.js
generated
vendored
Normal file
1
build/node_modules/seedrandom/seedrandom.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a,b){function c(c,j,k){var n=[];j=1==j?{entropy:!0}:j||{};var s=g(f(j.entropy?[c,i(a)]:null==c?h():c,3),n),t=new d(n),u=function(){for(var a=t.g(m),b=p,c=0;a<q;)a=(a+c)*l,b*=l,c=t.g(1);for(;a>=r;)a/=2,b/=2,c>>>=1;return(a+c)/b};return u.int32=function(){return 0|t.g(4)},u.quick=function(){return t.g(4)/4294967296},u.double=u,g(i(t.S),a),(j.pass||k||function(a,c,d,f){return f&&(f.S&&e(f,t),a.state=function(){return e(t,{})}),d?(b[o]=a,c):a})(u,s,"global"in j?j.global:this==b,j.state)}function d(a){var b,c=a.length,d=this,e=0,f=d.i=d.j=0,g=d.S=[];for(c||(a=[c++]);e<l;)g[e]=e++;for(e=0;e<l;e++)g[e]=g[f=s&f+a[e%c]+(b=g[e])],g[f]=b;(d.g=function(a){for(var b,c=0,e=d.i,f=d.j,g=d.S;a--;)b=g[e=s&e+1],c=c*l+g[s&(g[e]=g[f=s&f+b])+(g[f]=b)];return d.i=e,d.j=f,c})(l)}function e(a,b){return b.i=a.i,b.j=a.j,b.S=a.S.slice(),b}function f(a,b){var c,d=[],e=typeof a;if(b&&"object"==e)for(c in a)try{d.push(f(a[c],b-1))}catch(a){}return d.length?d:"string"==e?a:a+"\0"}function g(a,b){for(var c,d=a+"",e=0;e<d.length;)b[s&e]=s&(c^=19*b[s&e])+d.charCodeAt(e++);return i(b)}function h(){try{var b;return j&&(b=j.randomBytes)?b=b(l):(b=new Uint8Array(l),(k.crypto||k.msCrypto).getRandomValues(b)),i(b)}catch(b){var c=k.navigator,d=c&&c.plugins;return[+new Date,k,d,k.screen,i(a)]}}function i(a){return String.fromCharCode.apply(0,a)}var j,k=this,l=256,m=6,n=52,o="random",p=b.pow(l,m),q=b.pow(2,n),r=2*q,s=l-1;if(b["seed"+o]=c,g(b.random(),a),"object"==typeof module&&module.exports){module.exports=c;try{j=require("crypto")}catch(a){}}else"function"==typeof define&&define.amd&&define(function(){return c})}([],Math);
|
||||
30
build/node_modules/seedrandom/test/altprng.html
generated
vendored
Normal file
30
build/node_modules/seedrandom/test/altprng.html
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="lib/qunit.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="../lib/xor4096.min.js"></script>
|
||||
<script src="lib/qunit.js"></script>
|
||||
<script>
|
||||
QUnit.module("Alternative PRNG Test");
|
||||
|
||||
QUnit.test("Verify that we can use xor4096", function(assert) {
|
||||
// Use xor4096 for Richard Brent's xorgens-4096 algorithm.
|
||||
var xorgen = new xor4096('hello.');
|
||||
|
||||
// By default provides 32 bits of randomness in a float.
|
||||
assert.equal(xorgen(), 0.9798525865189731);
|
||||
|
||||
// Use "double" to get 56 bits of randomness.
|
||||
assert.equal(xorgen.double(), 0.03583478477375346);
|
||||
|
||||
// Use "int32" to get a 32 bit (signed) integer.
|
||||
assert.equal(xorgen.int32(), 1341429986);
|
||||
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
|
||||
|
||||
46
build/node_modules/seedrandom/test/autoseed.html
generated
vendored
Normal file
46
build/node_modules/seedrandom/test/autoseed.html
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="lib/qunit.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="lib/qunit.js"></script>
|
||||
<script src="../seedrandom.js"></script>
|
||||
<script>
|
||||
QUnit.module("Simple Test");
|
||||
|
||||
QUnit.test("Check that we can reproduce a seed", function(assert) {
|
||||
var seed;
|
||||
var time = new Date().getTime();
|
||||
var seediter = 50;
|
||||
for (var k = 0; k < seediter; ++k) {
|
||||
seed = Math.seedrandom();
|
||||
}
|
||||
var seedtime = (new Date().getTime() - time) / seediter;
|
||||
|
||||
time = new Date().getTime();
|
||||
var vals = [];
|
||||
var iters = 1000;
|
||||
var j;
|
||||
for (j = 0; j < iters; ++j) {
|
||||
var saw = Math.random();
|
||||
vals.push(saw);
|
||||
}
|
||||
time = new Date().getTime() - time;
|
||||
var errors = 0;
|
||||
Math.seedrandom(seed);
|
||||
for (j = 0; j < vals.length; ++j) {
|
||||
var saw = vals[j];
|
||||
var got = Math.random();
|
||||
assert.equal(saw, got, saw + " vs " + got);
|
||||
}
|
||||
|
||||
assert.ok(true, '' +
|
||||
'Seeding took ' + seedtime + ' ms per seedrandom' +
|
||||
' in ' + time + ' ms for ' + iters +
|
||||
' calls, ' + (time / iters) + ' ms per random()' + '');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
45
build/node_modules/seedrandom/test/bitgen.js
generated
vendored
Executable file
45
build/node_modules/seedrandom/test/bitgen.js
generated
vendored
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env node
|
||||
var seedrandom = require('../seedrandom');
|
||||
|
||||
// process.on('SIGPIPE', process.exit);
|
||||
function epipeBomb(stream, callback) {
|
||||
if (stream == null) stream = process.stdout;
|
||||
if (callback == null) callback = process.exit;
|
||||
|
||||
function epipeFilter(err) {
|
||||
if (err.code === 'EPIPE') return callback();
|
||||
|
||||
// If there's more than one error handler (ie, us),
|
||||
// then the error won't be bubbled up anyway
|
||||
if (stream.listeners('error').length <= 1) {
|
||||
stream.removeAllListeners(); // Pretend we were never here
|
||||
stream.emit('error', err); // Then emit as if we were never here
|
||||
stream.on('error', epipeFilter);// Reattach, ready for the next error!
|
||||
}
|
||||
}
|
||||
|
||||
stream.on('error', epipeFilter);
|
||||
}
|
||||
|
||||
epipeBomb();
|
||||
|
||||
var bufsize = 1024 * 256,
|
||||
buf = new Buffer(bufsize * 4),
|
||||
prng = seedrandom(0),
|
||||
count = parseInt(process.argv[2]) || Infinity;
|
||||
function dowrite() {
|
||||
while (count > 0) {
|
||||
for (var j = 0; j < bufsize; ++j) {
|
||||
buf.writeUInt32BE(Math.floor(
|
||||
prng() * 256 * 256 * 256 * 256
|
||||
), j * 4);
|
||||
}
|
||||
count -= bufsize * 32;
|
||||
if (!process.stdout.write(buf)) {
|
||||
process.stdout.once('drain', function() { setTimeout(dowrite, 0) });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dowrite();
|
||||
23
build/node_modules/seedrandom/test/browserified.html
generated
vendored
Normal file
23
build/node_modules/seedrandom/test/browserified.html
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="lib/qunit.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="lib/qunit.js"></script>
|
||||
<script>
|
||||
function describe(name, fn) {
|
||||
QUnit.module(name);
|
||||
fn();
|
||||
}
|
||||
function it(desc, fn) {
|
||||
QUnit.test(desc, function(a) {
|
||||
fn();
|
||||
a.ok(true);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script src="browserified.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
489
build/node_modules/seedrandom/test/browserified.js
generated
vendored
Normal file
489
build/node_modules/seedrandom/test/browserified.js
generated
vendored
Normal file
@@ -0,0 +1,489 @@
|
||||
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
|
||||
},{}],2:[function(require,module,exports){
|
||||
arguments[4][1][0].apply(exports,arguments)
|
||||
},{"dup":1}],3:[function(require,module,exports){
|
||||
/*
|
||||
Copyright 2014 David Bau.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
(function (pool, math) {
|
||||
//
|
||||
// The following constants are related to IEEE 754 limits.
|
||||
//
|
||||
var global = this,
|
||||
width = 256, // each RC4 output is 0 <= x < 256
|
||||
chunks = 6, // at least six RC4 outputs for each double
|
||||
digits = 52, // there are 52 significant digits in a double
|
||||
rngname = 'random', // rngname: name for Math.random and Math.seedrandom
|
||||
startdenom = math.pow(width, chunks),
|
||||
significance = math.pow(2, digits),
|
||||
overflow = significance * 2,
|
||||
mask = width - 1,
|
||||
nodecrypto; // node.js crypto module, initialized at the bottom.
|
||||
|
||||
//
|
||||
// seedrandom()
|
||||
// This is the seedrandom function described above.
|
||||
//
|
||||
function seedrandom(seed, options, callback) {
|
||||
var key = [];
|
||||
options = (options == true) ? { entropy: true } : (options || {});
|
||||
|
||||
// Flatten the seed string or build one from local entropy if needed.
|
||||
var shortseed = mixkey(flatten(
|
||||
options.entropy ? [seed, tostring(pool)] :
|
||||
(seed == null) ? autoseed() : seed, 3), key);
|
||||
|
||||
// Use the seed to initialize an ARC4 generator.
|
||||
var arc4 = new ARC4(key);
|
||||
|
||||
// This function returns a random double in [0, 1) that contains
|
||||
// randomness in every bit of the mantissa of the IEEE 754 value.
|
||||
var prng = function() {
|
||||
var n = arc4.g(chunks), // Start with a numerator n < 2 ^ 48
|
||||
d = startdenom, // and denominator d = 2 ^ 48.
|
||||
x = 0; // and no 'extra last byte'.
|
||||
while (n < significance) { // Fill up all significant digits by
|
||||
n = (n + x) * width; // shifting numerator and
|
||||
d *= width; // denominator and generating a
|
||||
x = arc4.g(1); // new least-significant-byte.
|
||||
}
|
||||
while (n >= overflow) { // To avoid rounding up, before adding
|
||||
n /= 2; // last byte, shift everything
|
||||
d /= 2; // right using integer math until
|
||||
x >>>= 1; // we have exactly the desired bits.
|
||||
}
|
||||
return (n + x) / d; // Form the number within [0, 1).
|
||||
};
|
||||
|
||||
prng.int32 = function() { return arc4.g(4) | 0; }
|
||||
prng.quick = function() { return arc4.g(4) / 0x100000000; }
|
||||
prng.double = prng;
|
||||
|
||||
// Mix the randomness into accumulated entropy.
|
||||
mixkey(tostring(arc4.S), pool);
|
||||
|
||||
// Calling convention: what to return as a function of prng, seed, is_math.
|
||||
return (options.pass || callback ||
|
||||
function(prng, seed, is_math_call, state) {
|
||||
if (state) {
|
||||
// Load the arc4 state from the given state if it has an S array.
|
||||
if (state.S) { copy(state, arc4); }
|
||||
// Only provide the .state method if requested via options.state.
|
||||
prng.state = function() { return copy(arc4, {}); }
|
||||
}
|
||||
|
||||
// If called as a method of Math (Math.seedrandom()), mutate
|
||||
// Math.random because that is how seedrandom.js has worked since v1.0.
|
||||
if (is_math_call) { math[rngname] = prng; return seed; }
|
||||
|
||||
// Otherwise, it is a newer calling convention, so return the
|
||||
// prng directly.
|
||||
else return prng;
|
||||
})(
|
||||
prng,
|
||||
shortseed,
|
||||
'global' in options ? options.global : (this == math),
|
||||
options.state);
|
||||
}
|
||||
math['seed' + rngname] = seedrandom;
|
||||
|
||||
//
|
||||
// ARC4
|
||||
//
|
||||
// An ARC4 implementation. The constructor takes a key in the form of
|
||||
// an array of at most (width) integers that should be 0 <= x < (width).
|
||||
//
|
||||
// The g(count) method returns a pseudorandom integer that concatenates
|
||||
// the next (count) outputs from ARC4. Its return value is a number x
|
||||
// that is in the range 0 <= x < (width ^ count).
|
||||
//
|
||||
function ARC4(key) {
|
||||
var t, keylen = key.length,
|
||||
me = this, i = 0, j = me.i = me.j = 0, s = me.S = [];
|
||||
|
||||
// The empty key [] is treated as [0].
|
||||
if (!keylen) { key = [keylen++]; }
|
||||
|
||||
// Set up S using the standard key scheduling algorithm.
|
||||
while (i < width) {
|
||||
s[i] = i++;
|
||||
}
|
||||
for (i = 0; i < width; i++) {
|
||||
s[i] = s[j = mask & (j + key[i % keylen] + (t = s[i]))];
|
||||
s[j] = t;
|
||||
}
|
||||
|
||||
// The "g" method returns the next (count) outputs as one number.
|
||||
(me.g = function(count) {
|
||||
// Using instance members instead of closure state nearly doubles speed.
|
||||
var t, r = 0,
|
||||
i = me.i, j = me.j, s = me.S;
|
||||
while (count--) {
|
||||
t = s[i = mask & (i + 1)];
|
||||
r = r * width + s[mask & ((s[i] = s[j = mask & (j + t)]) + (s[j] = t))];
|
||||
}
|
||||
me.i = i; me.j = j;
|
||||
return r;
|
||||
// For robust unpredictability, the function call below automatically
|
||||
// discards an initial batch of values. This is called RC4-drop[256].
|
||||
// See http://google.com/search?q=rsa+fluhrer+response&btnI
|
||||
})(width);
|
||||
}
|
||||
|
||||
//
|
||||
// copy()
|
||||
// Copies internal state of ARC4 to or from a plain object.
|
||||
//
|
||||
function copy(f, t) {
|
||||
t.i = f.i;
|
||||
t.j = f.j;
|
||||
t.S = f.S.slice();
|
||||
return t;
|
||||
};
|
||||
|
||||
//
|
||||
// flatten()
|
||||
// Converts an object tree to nested arrays of strings.
|
||||
//
|
||||
function flatten(obj, depth) {
|
||||
var result = [], typ = (typeof obj), prop;
|
||||
if (depth && typ == 'object') {
|
||||
for (prop in obj) {
|
||||
try { result.push(flatten(obj[prop], depth - 1)); } catch (e) {}
|
||||
}
|
||||
}
|
||||
return (result.length ? result : typ == 'string' ? obj : obj + '\0');
|
||||
}
|
||||
|
||||
//
|
||||
// mixkey()
|
||||
// Mixes a string seed into a key that is an array of integers, and
|
||||
// returns a shortened string seed that is equivalent to the result key.
|
||||
//
|
||||
function mixkey(seed, key) {
|
||||
var stringseed = seed + '', smear, j = 0;
|
||||
while (j < stringseed.length) {
|
||||
key[mask & j] =
|
||||
mask & ((smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++));
|
||||
}
|
||||
return tostring(key);
|
||||
}
|
||||
|
||||
//
|
||||
// autoseed()
|
||||
// Returns an object for autoseeding, using window.crypto and Node crypto
|
||||
// module if available.
|
||||
//
|
||||
function autoseed() {
|
||||
try {
|
||||
var out;
|
||||
if (nodecrypto && (out = nodecrypto.randomBytes)) {
|
||||
// The use of 'out' to remember randomBytes makes tight minified code.
|
||||
out = out(width);
|
||||
} else {
|
||||
out = new Uint8Array(width);
|
||||
(global.crypto || global.msCrypto).getRandomValues(out);
|
||||
}
|
||||
return tostring(out);
|
||||
} catch (e) {
|
||||
var browser = global.navigator,
|
||||
plugins = browser && browser.plugins;
|
||||
return [+new Date, global, plugins, global.screen, tostring(pool)];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// tostring()
|
||||
// Converts an array of charcodes to a string
|
||||
//
|
||||
function tostring(a) {
|
||||
return String.fromCharCode.apply(0, a);
|
||||
}
|
||||
|
||||
//
|
||||
// When seedrandom.js is loaded, we immediately mix a few bits
|
||||
// from the built-in RNG into the entropy pool. Because we do
|
||||
// not want to interfere with deterministic PRNG state later,
|
||||
// seedrandom will not call math.random on its own again after
|
||||
// initialization.
|
||||
//
|
||||
mixkey(math.random(), pool);
|
||||
|
||||
//
|
||||
// Nodejs and AMD support: export the implementation as a module using
|
||||
// either convention.
|
||||
//
|
||||
if ((typeof module) == 'object' && module.exports) {
|
||||
module.exports = seedrandom;
|
||||
// When in node.js, try using crypto package for autoseeding.
|
||||
try {
|
||||
nodecrypto = require('crypto');
|
||||
} catch (ex) {}
|
||||
} else if ((typeof define) == 'function' && define.amd) {
|
||||
define(function() { return seedrandom; });
|
||||
}
|
||||
|
||||
// End anonymous scope, and pass initial values.
|
||||
})(
|
||||
[], // pool: entropy pool starts empty
|
||||
Math // math: package containing random, pow, and seedrandom
|
||||
);
|
||||
|
||||
},{"crypto":1}],4:[function(require,module,exports){
|
||||
(function (__dirname){
|
||||
var assert = require("assert");
|
||||
var seedrandom = require("../seedrandom");
|
||||
var requirejs = require("requirejs");
|
||||
|
||||
// Stub out requirejs if in the browser via browserify.
|
||||
if (!requirejs.config) {
|
||||
requirejs = require;
|
||||
} else {
|
||||
requirejs.config({
|
||||
baseUrl: __dirname
|
||||
});
|
||||
}
|
||||
|
||||
describe("Nodejs API Test", function() {
|
||||
|
||||
it('should pass basic tests.', function() {
|
||||
var original = Math.random,
|
||||
result, r, xprng, obj, as2, as3, autoseed1, myrng,
|
||||
firstprng, secondprng, thirdprng, rng;
|
||||
|
||||
result = Math.seedrandom('hello.');
|
||||
firstprng = Math.random;
|
||||
assert.ok(original !== firstprng, "Should change Math.random.");
|
||||
assert.equal(result, "hello.", "Should return short seed.");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.3752569768646784, "Should be 'hello.'#2");
|
||||
|
||||
// should be able to autoseed
|
||||
result = Math.seedrandom();
|
||||
secondprng = Math.random;
|
||||
assert.ok(original !== secondprng, "Should change Math.random.");
|
||||
assert.ok(firstprng !== secondprng, "Should change Math.random.");
|
||||
assert.equal(result.length, 256, "Should return short seed.");
|
||||
r = Math.random();
|
||||
assert.ok(r > 0, "Should be posititive.");
|
||||
assert.ok(r < 1, "Should be less than 1.");
|
||||
assert.ok(r != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
assert.ok(r != 0.3752569768646784, "Should not be 'hello.'#2");
|
||||
assert.ok(r != 0.7316977468919549, "Should not be 'hello.'#3");
|
||||
autoseed1 = r;
|
||||
|
||||
// should be able to add entropy.
|
||||
result = Math.seedrandom('added entropy.', { entropy:true });
|
||||
assert.equal(result.length, 256, "Should return short seed.");
|
||||
thirdprng = Math.random;
|
||||
assert.ok(thirdprng !== secondprng, "Should change Math.random.");
|
||||
r = Math.random();
|
||||
assert.ok(r != 0.597067214994467, "Should not be 'added entropy.'#1");
|
||||
|
||||
// Reset to original Math.random.
|
||||
Math.random = original;
|
||||
// should be able to use new Math.seedrandom('hello.')
|
||||
myrng = new Math.seedrandom('hello.');
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== myrng, "PRNG should not be Math.random.");
|
||||
r = myrng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
|
||||
// should be able to use seedrandom('hello.')"
|
||||
rng = seedrandom('hello.');
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
r = rng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== rng, "PRNG should not be Math.random.");
|
||||
|
||||
// Global PRNG: set Math.random.
|
||||
// should be able to use seedrandom('hello.', { global: true })
|
||||
result = seedrandom('hello.', { global: true });
|
||||
assert.equal(result, 'hello.', "Should return short seed.");
|
||||
assert.ok(original != Math.random, "Should change Math.random.");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
|
||||
// Autoseeded non-global
|
||||
Math.random = original;
|
||||
// should be able to use seedrandom()
|
||||
result = seedrandom();
|
||||
assert.equal(typeof(result), 'function', "Should return function.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
r = result();
|
||||
// got " + r);
|
||||
assert.ok(r != autoseed1, "Should not repeat previous autoseed.");
|
||||
assert.ok(r != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
assert.ok(r != 0.7316977468919549, "Should not be 'hello.'#3");
|
||||
|
||||
// Mixing accumulated entropy.
|
||||
// should be able to use seedrandom('added entropy.', { entropy: true })
|
||||
rng = seedrandom('added entropy.', { entropy: true });
|
||||
r = result();
|
||||
// got " + r);
|
||||
assert.ok(r != autoseed1, "Should not repeat previous autoseed.");
|
||||
assert.ok(r != 0.597067214994467, "Should not be 'added entropy.'#1");
|
||||
|
||||
// Legacy calling convention for mixing accumulated entropy.
|
||||
// should be able to use seedrandom('added entropy.', true)
|
||||
rng = seedrandom('added entropy.', true);
|
||||
r = result();
|
||||
// got " + r);
|
||||
assert.ok(r != autoseed1, "Should not repeat previous autoseed.");
|
||||
assert.ok(r != 0.597067214994467, "Should not be 'added entropy.'#1");
|
||||
|
||||
// The pass option
|
||||
// should be able to use Math.seedrandom(null, { pass: ...
|
||||
obj = Math.seedrandom(null, { pass: function(prng, seed) {
|
||||
return { random: prng, seed: seed };
|
||||
}});
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== obj.random, "Should be different from Math.random.");
|
||||
assert.equal(typeof(obj.random), 'function', "Should return a PRNG function.");
|
||||
assert.equal(typeof(obj.seed), 'string', "Should return a seed.");
|
||||
as2 = obj.random();
|
||||
assert.ok(as2 != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
rng = seedrandom(obj.seed);
|
||||
as3 = rng();
|
||||
assert.equal(as2, as3, "Should be reproducible when using the seed.");
|
||||
|
||||
// Exercise pass again, with explicit seed and global
|
||||
// should be able to use Math.seedrandom('hello.', { pass: ...
|
||||
result = Math.seedrandom('hello.', {
|
||||
global: 'abc',
|
||||
pass: function(prng, seed, global) {
|
||||
assert.equal(typeof(prng), 'function', "Callback arg #1 assert");
|
||||
assert.equal(seed, 'hello.', "Callback arg #2 assert");
|
||||
assert.equal(global, 'abc', "Callback arg #3 passed through.");
|
||||
assert.equal(prng(), 0.9282578795792454, "Should be 'hello.'#1");
|
||||
return 'def';
|
||||
}});
|
||||
assert.equal(result, 'def', "Should return value from callback.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
|
||||
// Legacy third argument callback argument:
|
||||
// should be able to use Math.seedrandom('hello.', { global: 50 }, callback)
|
||||
result = Math.seedrandom('hello.', { global: 50 },
|
||||
function(prng, seed, global) {
|
||||
assert.equal(typeof(prng), 'function', "Callback arg #1 assert");
|
||||
assert.equal(seed, 'hello.', "Callback arg #2 assert");
|
||||
assert.equal(global, 50, "Callback arg #3 assert");
|
||||
assert.equal(prng(), 0.9282578795792454, "Should be 'hello.'#1");
|
||||
return 'zzz';
|
||||
});
|
||||
assert.equal(result, 'zzz', "Should return value from callback.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
|
||||
// Global: false.
|
||||
// should be able to use new Math.seedrandom('hello.', {global: false})
|
||||
myrng = new Math.seedrandom('hello.', {global:false});
|
||||
assert.equal(typeof(myrng), 'function', "Should return a PRNG funciton.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== myrng, "PRNG should not be Math.random.");
|
||||
r = myrng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
|
||||
// options = {} when a method of Math.
|
||||
// should be able to use Math.seedrandom('hello.', {})
|
||||
result = Math.seedrandom('hello.');
|
||||
xprng = Math.random;
|
||||
assert.ok(original !== xprng, "Should change Math.random.");
|
||||
assert.equal(result, "hello.", "Should return short seed.");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.3752569768646784, "Should be 'hello.'#2");
|
||||
Math.random = original;
|
||||
|
||||
// options = {} when not a method of Math
|
||||
// should be able to use seedrandom('hello.', {})
|
||||
rng = seedrandom('hello.', {});
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
r = rng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== rng, "PRNG should not be Math.random.");
|
||||
});
|
||||
|
||||
it('should support state api.', function() {
|
||||
// Verify that there is no state method
|
||||
var dummy = seedrandom('hello');
|
||||
var unexpected = -1;
|
||||
var expected = -1;
|
||||
try {
|
||||
unexpected = dummy.state();
|
||||
} catch(e) {
|
||||
expected = 1;
|
||||
}
|
||||
assert.equal(unexpected, -1);
|
||||
assert.equal(expected, 1);
|
||||
var count = 0;
|
||||
for (var x in dummy) {
|
||||
if (x == 'state') count += 1;
|
||||
}
|
||||
assert.equal(count, 0);
|
||||
|
||||
// Verify that a state method can be added
|
||||
var saveable = seedrandom("secret-seed", {state: true});
|
||||
var ordinary = seedrandom("secret-seed");
|
||||
for (var j = 0; j < 1e2; ++j) {
|
||||
assert.equal(ordinary(), saveable());
|
||||
}
|
||||
var virgin = seedrandom("secret-seed");
|
||||
var saved = saveable.state();
|
||||
var replica = seedrandom("", {state: saved});
|
||||
for (var j = 0; j < 1e2; ++j) {
|
||||
var r = replica();
|
||||
assert.equal(r, saveable());
|
||||
assert.equal(r, ordinary());
|
||||
assert.ok(r != virgin());
|
||||
}
|
||||
});
|
||||
|
||||
it('should support requirejs in node.', function() {
|
||||
var original = Math.random;
|
||||
var rsr = requirejs('../seedrandom');
|
||||
var rng = rsr('hello.');
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
var r = rng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== rng, "PRNG should not be Math.random.");
|
||||
});
|
||||
|
||||
// End of test.
|
||||
|
||||
});
|
||||
|
||||
}).call(this,"/test")
|
||||
},{"../seedrandom":3,"assert":"assert","requirejs":2}],"assert":[function(require,module,exports){
|
||||
// Use QUnit.assert to mimic node.assert.
|
||||
|
||||
module.exports = QUnit.assert;
|
||||
|
||||
},{}]},{},[4]);
|
||||
57
build/node_modules/seedrandom/test/cryptotest.js
generated
vendored
Normal file
57
build/node_modules/seedrandom/test/cryptotest.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
var proxyquire = require('proxyquire');
|
||||
var assert = require("assert");
|
||||
var Module = require("module");
|
||||
|
||||
describe("Crypto API Test", function() {
|
||||
|
||||
var crypto_stub = {};
|
||||
var original = Math.random;
|
||||
var rng, r;
|
||||
|
||||
// Load seedrandom in absence of any crypto package.
|
||||
it("should be able to seed without crypto", function() {
|
||||
var noncrypto_sr = proxyquire('../seedrandom', { crypto: null });
|
||||
rng = noncrypto_sr('hello.');
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
r = rng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
assert(original === Math.random, "Should not change Math.random.");
|
||||
assert(original !== rng, "PRNG should not be Math.random.");
|
||||
var noncrypto_sr = proxyquire('../seedrandom', { crypto: null });
|
||||
result = noncrypto_sr();
|
||||
assert.equal(typeof(result), 'function', "Should return function.");
|
||||
assert(original === Math.random, "Should not change Math.random.");
|
||||
r = result();
|
||||
assert(r != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
assert(r != 0.7316977468919549, "Should not be 'hello.'#3");
|
||||
assert(r != 0.23144008215179881, "Should not be '\\0'#1");
|
||||
assert(r != 0.7220382488550928, "Should not be '\\1'#1");
|
||||
// Recache original seedrandom.
|
||||
proxyquire('../seedrandom', {});
|
||||
});
|
||||
|
||||
// Load seedrandom with zeroed-out crypto package.
|
||||
it("should be able to seed ('hello.') with zero crypto", function() {
|
||||
var zerocrypto_sr = proxyquire('../seedrandom', {
|
||||
crypto: { randomBytes: function(n) {
|
||||
result = []; while (n-- > 0) { result.push(1); } return result; } }
|
||||
});
|
||||
rng = zerocrypto_sr('hello.');
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
r = rng();
|
||||
assert.equal(r, 0.9282578795792454 , "Should be 'hello.'#1");
|
||||
assert(original === Math.random, "Should not change Math.random.");
|
||||
assert(original !== rng, "PRNG should not be Math.random.");
|
||||
rng = zerocrypto_sr();
|
||||
assert.equal(typeof(rng), 'function', "Should return function.");
|
||||
assert(original === Math.random, "Should not change Math.random.");
|
||||
r = rng();
|
||||
assert.equal(r, 0.7220382488550928, "Should be '\\1'#1");
|
||||
r = rng();
|
||||
assert.equal(r, 0.0259971860493045, "Should be '\\1'#2");
|
||||
// Recache original seedrandom.
|
||||
proxyquire('../seedrandom', {});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
415
build/node_modules/seedrandom/test/lib/qunit.css
generated
vendored
Normal file
415
build/node_modules/seedrandom/test/lib/qunit.css
generated
vendored
Normal file
@@ -0,0 +1,415 @@
|
||||
/*!
|
||||
* QUnit 2.1.0
|
||||
* https://qunitjs.com/
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* https://jquery.org/license
|
||||
*
|
||||
* Date: 2016-12-06T04:45Z
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header (excluding toolbar) */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699A4;
|
||||
background-color: #0D3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: 400;
|
||||
|
||||
border-radius: 5px 5px 0 0;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #C2CCD1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-filteredTest {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
color: #366097;
|
||||
background-color: #F4FF77;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
color: #FFF;
|
||||
background-color: #2B81AF;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
|
||||
/** Toolbar */
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
color: #5E740B;
|
||||
background-color: #EEE;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar .clearfix {
|
||||
height: 0;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar input[type=checkbox],
|
||||
#qunit-testrunner-toolbar input[type=radio] {
|
||||
margin: 3px;
|
||||
vertical-align: -2px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar input[type=text] {
|
||||
box-sizing: border-box;
|
||||
height: 1.6em;
|
||||
}
|
||||
|
||||
.qunit-url-config,
|
||||
.qunit-filter,
|
||||
#qunit-modulefilter {
|
||||
display: inline-block;
|
||||
line-height: 2.1em;
|
||||
}
|
||||
|
||||
.qunit-filter,
|
||||
#qunit-modulefilter {
|
||||
float: right;
|
||||
position: relative;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.qunit-url-config label {
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-search {
|
||||
box-sizing: border-box;
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-search-container:after {
|
||||
position: absolute;
|
||||
right: 0.3em;
|
||||
content: "\25bc";
|
||||
color: black;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown {
|
||||
/* align with #qunit-modulefilter-search */
|
||||
box-sizing: border-box;
|
||||
width: 400px;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 50%;
|
||||
margin-top: 0.8em;
|
||||
|
||||
border: 1px solid #D3D3D3;
|
||||
border-top: none;
|
||||
border-radius: 0 0 .25em .25em;
|
||||
color: #000;
|
||||
background-color: #F5F5F5;
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown .clickable.checked {
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
background-color: #D2E0E6;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown .clickable:hover {
|
||||
color: #FFF;
|
||||
background-color: #0D3349;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-actions {
|
||||
display: block;
|
||||
overflow: auto;
|
||||
|
||||
/* align with #qunit-modulefilter-dropdown-list */
|
||||
font: smaller/1.5em sans-serif;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > * {
|
||||
box-sizing: border-box;
|
||||
max-height: 2.8em;
|
||||
display: block;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > button {
|
||||
float: right;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > :last-child {
|
||||
/* insert padding to align with checkbox margins */
|
||||
padding-left: 3px;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown-list {
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
margin: 0;
|
||||
border-top: 2px groove threedhighlight;
|
||||
padding: 0.4em 0 0;
|
||||
font: smaller/1.5em sans-serif;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown-list li {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-dropdown-list .clickable {
|
||||
display: block;
|
||||
padding-left: 0.15em;
|
||||
}
|
||||
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 1em 0.4em 1em;
|
||||
border-bottom: 1px solid #FFF;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests > li {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li.running,
|
||||
#qunit-tests li.pass,
|
||||
#qunit-tests li.fail,
|
||||
#qunit-tests li.skipped {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.running,
|
||||
#qunit-tests.hidepass li.pass {
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li.skipped strong {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #C2CCD1;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests li p a {
|
||||
padding: 0.25em;
|
||||
color: #6B6464;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests li .runtime {
|
||||
float: right;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.qunit-assert-list {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #FFF;
|
||||
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.qunit-source {
|
||||
margin: 0.6em 0 0.3em;
|
||||
}
|
||||
|
||||
.qunit-collapsed {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: 0.2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 0.5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
color: #374E0C;
|
||||
background-color: #E0F2BE;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
color: #500;
|
||||
background-color: #FFCACA;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: #000; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
padding: 5px;
|
||||
background-color: #FFF;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #3C510C;
|
||||
background-color: #FFF;
|
||||
border-left: 10px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #FFF;
|
||||
border-left: 10px solid #EE5757;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 5px 5px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: #008000; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
/*** Skipped tests */
|
||||
|
||||
#qunit-tests .skipped {
|
||||
background-color: #EBECE9;
|
||||
}
|
||||
|
||||
#qunit-tests .qunit-skipped-label {
|
||||
background-color: #F4FF77;
|
||||
display: inline-block;
|
||||
font-style: normal;
|
||||
color: #366097;
|
||||
line-height: 1.8em;
|
||||
padding: 0 0.5em;
|
||||
margin: -0.4em 0.4em -0.4em 0;
|
||||
}
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
|
||||
color: #2B81AF;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid #FFF;
|
||||
}
|
||||
#qunit-testresult .module-name {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
}
|
||||
4349
build/node_modules/seedrandom/test/lib/qunit.js
generated
vendored
Normal file
4349
build/node_modules/seedrandom/test/lib/qunit.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2142
build/node_modules/seedrandom/test/lib/require.js
generated
vendored
Normal file
2142
build/node_modules/seedrandom/test/lib/require.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
44
build/node_modules/seedrandom/test/newapi.html
generated
vendored
Normal file
44
build/node_modules/seedrandom/test/newapi.html
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="lib/qunit.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="lib/qunit.js"></script>
|
||||
<script src="../seedrandom.min.js"></script>
|
||||
<script>
|
||||
QUnit.module("New API Test");
|
||||
|
||||
QUnit.test("Check that we can use new", function(assert) {
|
||||
|
||||
assert.ok(true, "Seeded random created with new:");
|
||||
var check = [];
|
||||
var prng = new Math.seedrandom(1);
|
||||
var r;
|
||||
for (var j = 0; j < 5; ++j) {
|
||||
r = prng();
|
||||
assert.ok(true, r);
|
||||
check.push(r);
|
||||
}
|
||||
assert.ok(true, "Native random:");
|
||||
for (var j = 0; j < 5; ++j) {
|
||||
r = Math.random();
|
||||
assert.ok(true, r);
|
||||
check.push(r);
|
||||
}
|
||||
var seed = Math.seedrandom(1);
|
||||
assert.ok(true, "Overridden random without new " +
|
||||
"(return value " + seed + "):");
|
||||
for (var j = 0; j < 10; ++j) {
|
||||
r = Math.random();
|
||||
if (j < 5) {
|
||||
assert.equal(check[j], r, r + " vs " + check[j]);
|
||||
} else {
|
||||
assert.ok(check[j] != r, "unequal: " + r + " vs " + check[j]);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
226
build/node_modules/seedrandom/test/nodetest.js
generated
vendored
Normal file
226
build/node_modules/seedrandom/test/nodetest.js
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
var assert = require("assert");
|
||||
var seedrandom = require("../seedrandom");
|
||||
var requirejs = require("requirejs");
|
||||
|
||||
// Stub out requirejs if in the browser via browserify.
|
||||
if (!requirejs.config) {
|
||||
requirejs = require;
|
||||
} else {
|
||||
requirejs.config({
|
||||
baseUrl: __dirname
|
||||
});
|
||||
}
|
||||
|
||||
describe("Nodejs API Test", function() {
|
||||
|
||||
it('should pass basic tests.', function() {
|
||||
var original = Math.random,
|
||||
result, r, xprng, obj, as2, as3, autoseed1, myrng,
|
||||
firstprng, secondprng, thirdprng, rng;
|
||||
|
||||
result = Math.seedrandom('hello.');
|
||||
firstprng = Math.random;
|
||||
assert.ok(original !== firstprng, "Should change Math.random.");
|
||||
assert.equal(result, "hello.", "Should return short seed.");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.3752569768646784, "Should be 'hello.'#2");
|
||||
|
||||
// should be able to autoseed
|
||||
result = Math.seedrandom();
|
||||
secondprng = Math.random;
|
||||
assert.ok(original !== secondprng, "Should change Math.random.");
|
||||
assert.ok(firstprng !== secondprng, "Should change Math.random.");
|
||||
assert.equal(result.length, 256, "Should return short seed.");
|
||||
r = Math.random();
|
||||
assert.ok(r > 0, "Should be posititive.");
|
||||
assert.ok(r < 1, "Should be less than 1.");
|
||||
assert.ok(r != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
assert.ok(r != 0.3752569768646784, "Should not be 'hello.'#2");
|
||||
assert.ok(r != 0.7316977468919549, "Should not be 'hello.'#3");
|
||||
autoseed1 = r;
|
||||
|
||||
// should be able to add entropy.
|
||||
result = Math.seedrandom('added entropy.', { entropy:true });
|
||||
assert.equal(result.length, 256, "Should return short seed.");
|
||||
thirdprng = Math.random;
|
||||
assert.ok(thirdprng !== secondprng, "Should change Math.random.");
|
||||
r = Math.random();
|
||||
assert.ok(r != 0.597067214994467, "Should not be 'added entropy.'#1");
|
||||
|
||||
// Reset to original Math.random.
|
||||
Math.random = original;
|
||||
// should be able to use new Math.seedrandom('hello.')
|
||||
myrng = new Math.seedrandom('hello.');
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== myrng, "PRNG should not be Math.random.");
|
||||
r = myrng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
|
||||
// should be able to use seedrandom('hello.')"
|
||||
rng = seedrandom('hello.');
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
r = rng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== rng, "PRNG should not be Math.random.");
|
||||
|
||||
// Global PRNG: set Math.random.
|
||||
// should be able to use seedrandom('hello.', { global: true })
|
||||
result = seedrandom('hello.', { global: true });
|
||||
assert.equal(result, 'hello.', "Should return short seed.");
|
||||
assert.ok(original != Math.random, "Should change Math.random.");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
|
||||
// Autoseeded non-global
|
||||
Math.random = original;
|
||||
// should be able to use seedrandom()
|
||||
result = seedrandom();
|
||||
assert.equal(typeof(result), 'function', "Should return function.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
r = result();
|
||||
// got " + r);
|
||||
assert.ok(r != autoseed1, "Should not repeat previous autoseed.");
|
||||
assert.ok(r != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
assert.ok(r != 0.7316977468919549, "Should not be 'hello.'#3");
|
||||
|
||||
// Mixing accumulated entropy.
|
||||
// should be able to use seedrandom('added entropy.', { entropy: true })
|
||||
rng = seedrandom('added entropy.', { entropy: true });
|
||||
r = result();
|
||||
// got " + r);
|
||||
assert.ok(r != autoseed1, "Should not repeat previous autoseed.");
|
||||
assert.ok(r != 0.597067214994467, "Should not be 'added entropy.'#1");
|
||||
|
||||
// Legacy calling convention for mixing accumulated entropy.
|
||||
// should be able to use seedrandom('added entropy.', true)
|
||||
rng = seedrandom('added entropy.', true);
|
||||
r = result();
|
||||
// got " + r);
|
||||
assert.ok(r != autoseed1, "Should not repeat previous autoseed.");
|
||||
assert.ok(r != 0.597067214994467, "Should not be 'added entropy.'#1");
|
||||
|
||||
// The pass option
|
||||
// should be able to use Math.seedrandom(null, { pass: ...
|
||||
obj = Math.seedrandom(null, { pass: function(prng, seed) {
|
||||
return { random: prng, seed: seed };
|
||||
}});
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== obj.random, "Should be different from Math.random.");
|
||||
assert.equal(typeof(obj.random), 'function', "Should return a PRNG function.");
|
||||
assert.equal(typeof(obj.seed), 'string', "Should return a seed.");
|
||||
as2 = obj.random();
|
||||
assert.ok(as2 != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
rng = seedrandom(obj.seed);
|
||||
as3 = rng();
|
||||
assert.equal(as2, as3, "Should be reproducible when using the seed.");
|
||||
|
||||
// Exercise pass again, with explicit seed and global
|
||||
// should be able to use Math.seedrandom('hello.', { pass: ...
|
||||
result = Math.seedrandom('hello.', {
|
||||
global: 'abc',
|
||||
pass: function(prng, seed, global) {
|
||||
assert.equal(typeof(prng), 'function', "Callback arg #1 assert");
|
||||
assert.equal(seed, 'hello.', "Callback arg #2 assert");
|
||||
assert.equal(global, 'abc', "Callback arg #3 passed through.");
|
||||
assert.equal(prng(), 0.9282578795792454, "Should be 'hello.'#1");
|
||||
return 'def';
|
||||
}});
|
||||
assert.equal(result, 'def', "Should return value from callback.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
|
||||
// Legacy third argument callback argument:
|
||||
// should be able to use Math.seedrandom('hello.', { global: 50 }, callback)
|
||||
result = Math.seedrandom('hello.', { global: 50 },
|
||||
function(prng, seed, global) {
|
||||
assert.equal(typeof(prng), 'function', "Callback arg #1 assert");
|
||||
assert.equal(seed, 'hello.', "Callback arg #2 assert");
|
||||
assert.equal(global, 50, "Callback arg #3 assert");
|
||||
assert.equal(prng(), 0.9282578795792454, "Should be 'hello.'#1");
|
||||
return 'zzz';
|
||||
});
|
||||
assert.equal(result, 'zzz', "Should return value from callback.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
|
||||
// Global: false.
|
||||
// should be able to use new Math.seedrandom('hello.', {global: false})
|
||||
myrng = new Math.seedrandom('hello.', {global:false});
|
||||
assert.equal(typeof(myrng), 'function', "Should return a PRNG funciton.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== myrng, "PRNG should not be Math.random.");
|
||||
r = myrng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
|
||||
// options = {} when a method of Math.
|
||||
// should be able to use Math.seedrandom('hello.', {})
|
||||
result = Math.seedrandom('hello.');
|
||||
xprng = Math.random;
|
||||
assert.ok(original !== xprng, "Should change Math.random.");
|
||||
assert.equal(result, "hello.", "Should return short seed.");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
r = Math.random();
|
||||
assert.equal(r, 0.3752569768646784, "Should be 'hello.'#2");
|
||||
Math.random = original;
|
||||
|
||||
// options = {} when not a method of Math
|
||||
// should be able to use seedrandom('hello.', {})
|
||||
rng = seedrandom('hello.', {});
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
r = rng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== rng, "PRNG should not be Math.random.");
|
||||
});
|
||||
|
||||
it('should support state api.', function() {
|
||||
// Verify that there is no state method
|
||||
var dummy = seedrandom('hello');
|
||||
var unexpected = -1;
|
||||
var expected = -1;
|
||||
try {
|
||||
unexpected = dummy.state();
|
||||
} catch(e) {
|
||||
expected = 1;
|
||||
}
|
||||
assert.equal(unexpected, -1);
|
||||
assert.equal(expected, 1);
|
||||
var count = 0;
|
||||
for (var x in dummy) {
|
||||
if (x == 'state') count += 1;
|
||||
}
|
||||
assert.equal(count, 0);
|
||||
|
||||
// Verify that a state method can be added
|
||||
var saveable = seedrandom("secret-seed", {state: true});
|
||||
var ordinary = seedrandom("secret-seed");
|
||||
for (var j = 0; j < 1e2; ++j) {
|
||||
assert.equal(ordinary(), saveable());
|
||||
}
|
||||
var virgin = seedrandom("secret-seed");
|
||||
var saved = saveable.state();
|
||||
var replica = seedrandom("", {state: saved});
|
||||
for (var j = 0; j < 1e2; ++j) {
|
||||
var r = replica();
|
||||
assert.equal(r, saveable());
|
||||
assert.equal(r, ordinary());
|
||||
assert.ok(r != virgin());
|
||||
}
|
||||
});
|
||||
|
||||
it('should support requirejs in node.', function() {
|
||||
var original = Math.random;
|
||||
var rsr = requirejs('../seedrandom');
|
||||
var rng = rsr('hello.');
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
var r = rng();
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== rng, "PRNG should not be Math.random.");
|
||||
});
|
||||
|
||||
// End of test.
|
||||
|
||||
});
|
||||
195
build/node_modules/seedrandom/test/options.html
generated
vendored
Normal file
195
build/node_modules/seedrandom/test/options.html
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="lib/qunit.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="../seedrandom.min.js"></script>
|
||||
<script src="lib/qunit.js"></script>
|
||||
<script>
|
||||
QUnit.module("Options API Test");
|
||||
|
||||
QUnit.test("Verify that we can use documented options", function(assert) {
|
||||
assert.ok(true, "Seeded random created with new:");
|
||||
|
||||
var original = Math.random;
|
||||
|
||||
assert.ok(true, "Using Math.seedrandom('hello.')");
|
||||
var result = Math.seedrandom('hello.');
|
||||
var firstprng = Math.random;
|
||||
assert.ok(original !== firstprng, "Should change Math.random.");
|
||||
assert.equal(result, "hello.", "Should return short seed.");
|
||||
var r = Math.random();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
r = Math.random();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.equal(r, 0.3752569768646784, "Should be 'hello.'#2");
|
||||
|
||||
assert.ok(true, "Using Math.seedrandom()");
|
||||
result = Math.seedrandom();
|
||||
var secondprng = Math.random;
|
||||
assert.ok(original !== secondprng, "Should change Math.random.");
|
||||
assert.ok(firstprng !== secondprng, "Should change Math.random.");
|
||||
assert.equal(result.length, 256, "Should return short seed.");
|
||||
r = Math.random();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.ok(r != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
assert.ok(r != 0.7316977468919549, "Should not be 'hello.'#3");
|
||||
var autoseed1 = r;
|
||||
|
||||
assert.ok(true, "Using Math.seedrandom('added entropy.', { entropy:true })");
|
||||
result = Math.seedrandom('added entropy.', { entropy:true });
|
||||
assert.equal(result.length, 256, "Should return short seed.");
|
||||
var thirdprng = Math.random;
|
||||
assert.ok(thirdprng !== secondprng, "Should change Math.random.");
|
||||
r = Math.random();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.ok(r != 0.597067214994467, "Should not be 'added entropy.'#1");
|
||||
|
||||
// Reset to original Math.random.
|
||||
Math.random = original;
|
||||
assert.ok(true, "Using new Math.seedrandom('hello.')");
|
||||
var myrng = new Math.seedrandom('hello.');
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== myrng, "PRNG should not be Math.random.");
|
||||
r = myrng();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
|
||||
// Use "quick" to get only 32 bits of randomness in a float.
|
||||
assert.equal(myrng.quick(), 0.3752569768112153, "Should be quick #1.1");
|
||||
|
||||
// Use "int32" to get a 32 bit (signed) integer
|
||||
assert.equal(myrng.int32(), 986220731, "Should be int32 #1.2");
|
||||
|
||||
// As if brought in by node.js
|
||||
var seedrandom = Math.seedrandom;
|
||||
|
||||
assert.ok(true, "Using seedrandom('hello.')");
|
||||
var rng = seedrandom('hello.');
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
r = rng();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== rng, "PRNG should not be Math.random.");
|
||||
|
||||
// Global PRNG: set Math.random.
|
||||
assert.ok(true, "Using seedrandom('hello.', { global: true })");
|
||||
result = seedrandom('hello.', { global: true });
|
||||
assert.equal(result, 'hello.', "Should return short seed.");
|
||||
assert.ok(original != Math.random, "Should change Math.random.");
|
||||
r = Math.random();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
|
||||
// Autoseeded non-global
|
||||
Math.random = original;
|
||||
assert.ok(true, "Using seedrandom()");
|
||||
result = seedrandom();
|
||||
assert.equal(typeof(result), 'function', "Should return function.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
r = result();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.ok(r != autoseed1, "Should not repeat previous autoseed.");
|
||||
assert.ok(r != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
assert.ok(r != 0.7316977468919549, "Should not be 'hello.'#3");
|
||||
|
||||
// Mixing accumulated entropy.
|
||||
assert.ok(true, "Using seedrandom('added entropy.', { entropy: true })");
|
||||
rng = seedrandom('added entropy.', { entropy: true });
|
||||
r = result();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.ok(r != autoseed1, "Should not repeat previous autoseed.");
|
||||
assert.ok(r != 0.597067214994467, "Should not be 'added entropy.'#1");
|
||||
|
||||
// Legacy calling convention for mixing accumulated entropy.
|
||||
assert.ok(true, "Using seedrandom('added entropy.', true)");
|
||||
rng = seedrandom('added entropy.', true);
|
||||
r = result();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.ok(r != autoseed1, "Should not repeat previous autoseed.");
|
||||
assert.ok(r != 0.597067214994467, "Should not be 'added entropy.'#1");
|
||||
|
||||
// The pass option
|
||||
assert.ok(true, "Using Math.seedrandom(null, { pass: ...");
|
||||
var obj = Math.seedrandom(null, { pass: function(prng, seed) {
|
||||
return { random: prng, seed: seed };
|
||||
}});
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== obj.random, "Should be different from Math.random.");
|
||||
assert.equal(typeof(obj.random), 'function', "Should return a PRNG function.");
|
||||
assert.equal(typeof(obj.seed), 'string', "Should return a seed.");
|
||||
var as2 = obj.random();
|
||||
assert.ok(as2 != 0.9282578795792454, "Should not be 'hello.'#1");
|
||||
rng = seedrandom(obj.seed);
|
||||
var as3 = rng();
|
||||
assert.equal(as2, as3, "Should be reproducible when using the seed.");
|
||||
|
||||
// Exercise pass again, with explicit seed and global
|
||||
assert.ok(true, "Using Math.seedrandom('hello.', { pass: ...");
|
||||
result = Math.seedrandom('hello.', {
|
||||
global: 'abc',
|
||||
pass: function(prng, seed, global) {
|
||||
assert.equal(typeof(prng), 'function', "Callback arg #1 assert.ok");
|
||||
assert.equal(seed, 'hello.', "Callback arg #2 assert.ok");
|
||||
assert.equal(global, 'abc', "Callback arg #3 passed through.");
|
||||
assert.equal(prng(), 0.9282578795792454, "Should be 'hello.'#1");
|
||||
return 'def';
|
||||
}});
|
||||
assert.equal(result, 'def', "Should return value from callback.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
|
||||
// Legacy third argument callback argument:
|
||||
assert.ok(true, "Using Math.seedrandom('hello.', { global: 50 }, callback)");
|
||||
result = Math.seedrandom('hello.', { global: 50 },
|
||||
function(prng, seed, global) {
|
||||
assert.equal(typeof(prng), 'function', "Callback arg #1 assert.ok");
|
||||
assert.equal(seed, 'hello.', "Callback arg #2 assert.ok");
|
||||
assert.equal(global, 50, "Callback arg #3 assert.ok");
|
||||
assert.equal(prng(), 0.9282578795792454, "Should be 'hello.'#1");
|
||||
return 'zzz';
|
||||
});
|
||||
assert.equal(result, 'zzz', "Should return value from callback.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
|
||||
// Global: false.
|
||||
assert.ok(true, "Using new Math.seedrandom('hello.', {global: false})");
|
||||
myrng = new Math.seedrandom('hello.', {global:false});
|
||||
assert.equal(typeof(myrng), 'function', "Should return a PRNG funciton.");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== myrng, "PRNG should not be Math.random.");
|
||||
r = myrng();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
|
||||
// options = {} when a method of Math.
|
||||
assert.ok(true, "Using Math.seedrandom('hello.', {})");
|
||||
var result = Math.seedrandom('hello.');
|
||||
var xprng = Math.random;
|
||||
assert.ok(original !== xprng, "Should change Math.random.");
|
||||
assert.equal(result, "hello.", "Should return short seed.");
|
||||
var r = Math.random();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
r = Math.random();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.equal(r, 0.3752569768646784, "Should be 'hello.'#2");
|
||||
Math.random = original;
|
||||
|
||||
// options = {} when not a method of Math
|
||||
assert.ok(true, "Using seedrandom('hello.', {})");
|
||||
rng = seedrandom('hello.', {});
|
||||
assert.equal(typeof(rng), 'function', "Should return a function.");
|
||||
r = rng();
|
||||
assert.ok(true, "Got " + r);
|
||||
assert.equal(r, 0.9282578795792454, "Should be 'hello.'#1");
|
||||
assert.ok(original === Math.random, "Should not change Math.random.");
|
||||
assert.ok(original !== rng, "PRNG should not be Math.random.");
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
125
build/node_modules/seedrandom/test/out/dieharder-report.txt
generated
vendored
Normal file
125
build/node_modules/seedrandom/test/out/dieharder-report.txt
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
#=============================================================================#
|
||||
# dieharder version 3.31.1 Copyright 2003 Robert G. Brown #
|
||||
#=============================================================================#
|
||||
rng_name |rands/second| Seed |
|
||||
stdin_input_raw| 8.07e+05 | 254212981|
|
||||
#=============================================================================#
|
||||
test_name |ntup| tsamples |psamples| p-value |Assessment
|
||||
#=============================================================================#
|
||||
diehard_birthdays| 0| 100| 100|0.55960061| PASSED
|
||||
diehard_operm5| 0| 1000000| 100|0.10062010| PASSED
|
||||
diehard_rank_32x32| 0| 40000| 100|0.70957907| PASSED
|
||||
diehard_rank_6x8| 0| 100000| 100|0.55953143| PASSED
|
||||
diehard_bitstream| 0| 2097152| 100|0.22843857| PASSED
|
||||
diehard_opso| 0| 2097152| 100|0.72251086| PASSED
|
||||
diehard_oqso| 0| 2097152| 100|0.30642074| PASSED
|
||||
diehard_dna| 0| 2097152| 100|0.30448899| PASSED
|
||||
diehard_count_1s_str| 0| 256000| 100|0.23557064| PASSED
|
||||
diehard_count_1s_byt| 0| 256000| 100|0.71300874| PASSED
|
||||
diehard_parking_lot| 0| 12000| 100|0.88217430| PASSED
|
||||
diehard_2dsphere| 2| 8000| 100|0.32366362| PASSED
|
||||
diehard_3dsphere| 3| 4000| 100|0.30804215| PASSED
|
||||
diehard_squeeze| 0| 100000| 100|0.97856588| PASSED
|
||||
diehard_sums| 0| 100| 100|0.01512286| PASSED
|
||||
diehard_runs| 0| 100000| 100|0.39065054| PASSED
|
||||
diehard_runs| 0| 100000| 100|0.10369088| PASSED
|
||||
diehard_craps| 0| 200000| 100|0.57875078| PASSED
|
||||
diehard_craps| 0| 200000| 100|0.96945165| PASSED
|
||||
marsaglia_tsang_gcd| 0| 10000000| 100|0.58793715| PASSED
|
||||
marsaglia_tsang_gcd| 0| 10000000| 100|0.59724594| PASSED
|
||||
sts_monobit| 1| 100000| 100|0.49155110| PASSED
|
||||
sts_runs| 2| 100000| 100|0.01880740| PASSED
|
||||
sts_serial| 1| 100000| 100|0.79060354| PASSED
|
||||
sts_serial| 2| 100000| 100|0.91055644| PASSED
|
||||
sts_serial| 3| 100000| 100|0.15984346| PASSED
|
||||
sts_serial| 3| 100000| 100|0.04426690| PASSED
|
||||
sts_serial| 4| 100000| 100|0.31589675| PASSED
|
||||
sts_serial| 4| 100000| 100|0.65789943| PASSED
|
||||
sts_serial| 5| 100000| 100|0.84228003| PASSED
|
||||
sts_serial| 5| 100000| 100|0.28748169| PASSED
|
||||
sts_serial| 6| 100000| 100|0.00092985| WEAK
|
||||
sts_serial| 6| 100000| 100|0.06074248| PASSED
|
||||
sts_serial| 7| 100000| 100|0.54740122| PASSED
|
||||
sts_serial| 7| 100000| 100|0.30286638| PASSED
|
||||
sts_serial| 8| 100000| 100|0.56593073| PASSED
|
||||
sts_serial| 8| 100000| 100|0.48256390| PASSED
|
||||
sts_serial| 9| 100000| 100|0.70850963| PASSED
|
||||
sts_serial| 9| 100000| 100|0.63732762| PASSED
|
||||
sts_serial| 10| 100000| 100|0.70209276| PASSED
|
||||
sts_serial| 10| 100000| 100|0.99576606| WEAK
|
||||
sts_serial| 11| 100000| 100|0.96272563| PASSED
|
||||
sts_serial| 11| 100000| 100|0.76682898| PASSED
|
||||
sts_serial| 12| 100000| 100|0.51522677| PASSED
|
||||
sts_serial| 12| 100000| 100|0.49381681| PASSED
|
||||
sts_serial| 13| 100000| 100|0.24260261| PASSED
|
||||
sts_serial| 13| 100000| 100|0.41953338| PASSED
|
||||
sts_serial| 14| 100000| 100|0.34770045| PASSED
|
||||
sts_serial| 14| 100000| 100|0.16117277| PASSED
|
||||
sts_serial| 15| 100000| 100|0.27319992| PASSED
|
||||
sts_serial| 15| 100000| 100|0.61170864| PASSED
|
||||
sts_serial| 16| 100000| 100|0.90638742| PASSED
|
||||
sts_serial| 16| 100000| 100|0.60186602| PASSED
|
||||
rgb_bitdist| 1| 100000| 100|0.72630216| PASSED
|
||||
rgb_bitdist| 2| 100000| 100|0.61396597| PASSED
|
||||
rgb_bitdist| 3| 100000| 100|0.40711729| PASSED
|
||||
rgb_bitdist| 4| 100000| 100|0.94730365| PASSED
|
||||
rgb_bitdist| 5| 100000| 100|0.95781972| PASSED
|
||||
rgb_bitdist| 6| 100000| 100|0.15054771| PASSED
|
||||
rgb_bitdist| 7| 100000| 100|0.25022202| PASSED
|
||||
rgb_bitdist| 8| 100000| 100|0.66027754| PASSED
|
||||
rgb_bitdist| 9| 100000| 100|0.86566842| PASSED
|
||||
rgb_bitdist| 10| 100000| 100|0.55219204| PASSED
|
||||
rgb_bitdist| 11| 100000| 100|0.73446935| PASSED
|
||||
rgb_bitdist| 12| 100000| 100|0.99761332| WEAK
|
||||
rgb_minimum_distance| 2| 10000| 1000|0.42222311| PASSED
|
||||
rgb_minimum_distance| 3| 10000| 1000|0.81566417| PASSED
|
||||
rgb_minimum_distance| 4| 10000| 1000|0.84024874| PASSED
|
||||
rgb_minimum_distance| 5| 10000| 1000|0.37732026| PASSED
|
||||
rgb_permutations| 2| 100000| 100|0.10996142| PASSED
|
||||
rgb_permutations| 3| 100000| 100|0.64682554| PASSED
|
||||
rgb_permutations| 4| 100000| 100|0.75843859| PASSED
|
||||
rgb_permutations| 5| 100000| 100|0.95248930| PASSED
|
||||
rgb_lagged_sum| 0| 1000000| 100|0.57812648| PASSED
|
||||
rgb_lagged_sum| 1| 1000000| 100|0.67863162| PASSED
|
||||
rgb_lagged_sum| 2| 1000000| 100|0.70003210| PASSED
|
||||
rgb_lagged_sum| 3| 1000000| 100|0.50312943| PASSED
|
||||
rgb_lagged_sum| 4| 1000000| 100|0.80009739| PASSED
|
||||
rgb_lagged_sum| 5| 1000000| 100|0.66383600| PASSED
|
||||
rgb_lagged_sum| 6| 1000000| 100|0.65640392| PASSED
|
||||
rgb_lagged_sum| 7| 1000000| 100|0.10710511| PASSED
|
||||
rgb_lagged_sum| 8| 1000000| 100|0.70414014| PASSED
|
||||
rgb_lagged_sum| 9| 1000000| 100|0.63857571| PASSED
|
||||
rgb_lagged_sum| 10| 1000000| 100|0.25221229| PASSED
|
||||
rgb_lagged_sum| 11| 1000000| 100|0.04199433| PASSED
|
||||
rgb_lagged_sum| 12| 1000000| 100|0.82738115| PASSED
|
||||
rgb_lagged_sum| 13| 1000000| 100|0.28316509| PASSED
|
||||
rgb_lagged_sum| 14| 1000000| 100|0.21184422| PASSED
|
||||
rgb_lagged_sum| 15| 1000000| 100|0.35537687| PASSED
|
||||
rgb_lagged_sum| 16| 1000000| 100|0.40157319| PASSED
|
||||
rgb_lagged_sum| 17| 1000000| 100|0.98108259| PASSED
|
||||
rgb_lagged_sum| 18| 1000000| 100|0.65892868| PASSED
|
||||
rgb_lagged_sum| 19| 1000000| 100|0.61659671| PASSED
|
||||
rgb_lagged_sum| 20| 1000000| 100|0.21462018| PASSED
|
||||
rgb_lagged_sum| 21| 1000000| 100|0.94489214| PASSED
|
||||
rgb_lagged_sum| 22| 1000000| 100|0.76019491| PASSED
|
||||
rgb_lagged_sum| 23| 1000000| 100|0.21024028| PASSED
|
||||
rgb_lagged_sum| 24| 1000000| 100|0.25249456| PASSED
|
||||
rgb_lagged_sum| 25| 1000000| 100|0.87385459| PASSED
|
||||
rgb_lagged_sum| 26| 1000000| 100|0.81553540| PASSED
|
||||
rgb_lagged_sum| 27| 1000000| 100|0.94450657| PASSED
|
||||
rgb_lagged_sum| 28| 1000000| 100|0.82470366| PASSED
|
||||
rgb_lagged_sum| 29| 1000000| 100|0.93993722| PASSED
|
||||
rgb_lagged_sum| 30| 1000000| 100|0.52675692| PASSED
|
||||
rgb_lagged_sum| 31| 1000000| 100|0.59975558| PASSED
|
||||
rgb_lagged_sum| 32| 1000000| 100|0.27951088| PASSED
|
||||
rgb_kstest_test| 0| 10000| 1000|0.49707175| PASSED
|
||||
dab_bytedistrib| 0| 51200000| 1|0.73019918| PASSED
|
||||
dab_dct| 256| 50000| 1|0.33856081| PASSED
|
||||
Preparing to run test 207. ntuple = 0
|
||||
dab_filltree| 32| 15000000| 1|0.92953640| PASSED
|
||||
dab_filltree| 32| 15000000| 1|0.10970674| PASSED
|
||||
Preparing to run test 208. ntuple = 0
|
||||
dab_filltree2| 0| 5000000| 1|0.88411850| PASSED
|
||||
dab_filltree2| 1| 5000000| 1|0.56835378| PASSED
|
||||
Preparing to run test 209. ntuple = 0
|
||||
dab_monobit2| 12| 65000000| 1|0.07987839| PASSED
|
||||
122
build/node_modules/seedrandom/test/prngtest.js
generated
vendored
Normal file
122
build/node_modules/seedrandom/test/prngtest.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
// A simple smoke test and benchmark for the generators.
|
||||
|
||||
var assert = require('assert');
|
||||
var xor128 = require('../lib/xor128');
|
||||
var xorwow = require('../lib/xorwow');
|
||||
var xs7 = require('../lib/xorshift7');
|
||||
var xor4096 = require('../lib/xor4096');
|
||||
var tychei = require('../lib/tychei');
|
||||
var alea = require('../lib/alea');
|
||||
var sr = require('../seedrandom');
|
||||
|
||||
describe("XOR-Shift generator test", function() {
|
||||
|
||||
var benchmarks = { native: { rand: Math.random, times: [] } };
|
||||
|
||||
function test(label, alg, double1, float3, int4, hc, qc, ec, e2c) {
|
||||
var fn = alg(1);
|
||||
var fn2 = alg('hello.', { state: true });
|
||||
benchmarks[label] = {rand: fn.quick, times: []};
|
||||
it("should use " + label + " correctly", function() {
|
||||
if (double1 != null) assert.equal(fn.double(), double1);
|
||||
if (float3 != null) assert.equal(fn.quick(), float3);
|
||||
if (int4 != null) assert.equal(fn.int32(), int4);
|
||||
assert(fn() > 0);
|
||||
assert(fn() < 1);
|
||||
assert(fn2() > 0);
|
||||
// Internal state is visible only if requested.
|
||||
assert(!('state' in fn));
|
||||
assert('state' in fn2);
|
||||
var ss = fn2.state();
|
||||
var rs = fn2();
|
||||
assert(rs < 1);
|
||||
var j, h = 0, q = 0, e = 0, r, p, e2 = 0;
|
||||
for (j = 0; j < 1024; ++j) {
|
||||
r = fn();
|
||||
if (r < 0.5) h += 1;
|
||||
if (r < 0.25) q += 1;
|
||||
if (r < 0.125) e += 1;
|
||||
r2 = fn2();
|
||||
if (r2 < 0.125) e2 += 1;
|
||||
}
|
||||
if (hc != null) {
|
||||
assert.equal(h, hc);
|
||||
assert.equal(q, qc);
|
||||
assert.equal(e, ec);
|
||||
assert.equal(e2, e2c);
|
||||
h = q = e = p = 0;
|
||||
for (j = 0; j < 1024; ++j) {
|
||||
r = fn.double();
|
||||
if (r < 0.5) h += 1;
|
||||
if (r < 0.25) q += 1;
|
||||
if (r < 0.125) e += 1;
|
||||
if (fn.int32() >= 0) p += 1;
|
||||
}
|
||||
// Sanity-check double() and int32.
|
||||
assert(h >= 480 && h <= 543, h);
|
||||
assert(q >= 226 && q <= 286, q);
|
||||
assert(e >= 100 && e <= 156, e);
|
||||
assert(e2 >= 100 && e2 <= 156, e2);
|
||||
assert(p >= 482 && p <= 543, p);
|
||||
}
|
||||
var fn3 = alg(0, { state: ss });
|
||||
assert.equal(fn3(), rs);
|
||||
});
|
||||
}
|
||||
|
||||
test("xor128", xor128,
|
||||
0.7963797148975774, 0.22171171731315553, 317177041, 498, 236, 110, 115);
|
||||
test("xorwow", xorwow,
|
||||
0.8178000247146859, 0.8407576507888734, 533150816, 519, 228, 121, 123);
|
||||
test("xorshift7", xs7,
|
||||
0.21241471533241418, 0.9957620368804783, -1678071207, 510, 261, 143, 124);
|
||||
test("tychei", tychei,
|
||||
0.42331440041340196, 0.9365617581643164, -884984569, 521, 242, 116, 126);
|
||||
test("seedrandom", sr,
|
||||
0.1776348083296759, 0.2160690303426236, 1397712774, 526, 282, 131, 137);
|
||||
test("xor4096", xor4096,
|
||||
0.1520436450538547, 0.4206166828516871, 1312695376, 496, 241, 113, 142);
|
||||
test("alea", alea,
|
||||
0.5260470956849501, 0.47771977609954774, -1625913352, 494, 246, 125, 122);
|
||||
|
||||
it("runs benchmarks", function() {
|
||||
var n = 4;
|
||||
var trials = 10;
|
||||
var top = 4;
|
||||
this.timeout(200 * n * trials);
|
||||
this.slow(30 * n * trials);
|
||||
var fn, k, start, end, j, t;
|
||||
for (k in benchmarks) {
|
||||
fn = benchmarks[k].rand;
|
||||
// warmup.
|
||||
for (j = 0; j < 1e5; ++j) fn();
|
||||
}
|
||||
for (t = 0; t < trials; ++t) {
|
||||
for (k in benchmarks) {
|
||||
fn = benchmarks[k].rand;
|
||||
start = +new Date;
|
||||
// benchmark.
|
||||
for (j = 0; j < n * 1e5; ++j) fn();
|
||||
end = +new Date;
|
||||
benchmarks[k].times.push(end - start);
|
||||
}
|
||||
}
|
||||
for (k in benchmarks) {
|
||||
benchmarks[k].times.sort();
|
||||
}
|
||||
function fastest(array) {
|
||||
var sum = 0;
|
||||
for (var j = 0; j < top; ++j) {
|
||||
sum += array[j];
|
||||
}
|
||||
return sum / top;
|
||||
}
|
||||
var nativetime = fastest(benchmarks.native.times);
|
||||
for (k in benchmarks) {
|
||||
var time = fastest(benchmarks[k].times);
|
||||
console.log(k+ ': ' + time / n + ' nanoseconds per call, ' +
|
||||
(time / nativetime).toFixed(1) + 'x native random.');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
3
build/node_modules/seedrandom/test/qunitassert.js
generated
vendored
Normal file
3
build/node_modules/seedrandom/test/qunitassert.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// Use QUnit.assert to mimic node.assert.
|
||||
|
||||
module.exports = QUnit.assert;
|
||||
57
build/node_modules/seedrandom/test/require.html
generated
vendored
Normal file
57
build/node_modules/seedrandom/test/require.html
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="lib/qunit.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="lib/require.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
require.config({
|
||||
paths: {
|
||||
'qunit': 'lib/qunit',
|
||||
'seedrandom': '/seedrandom.min'
|
||||
}
|
||||
});
|
||||
|
||||
require(['qunit', 'seedrandom'], function(QUnit, seedrandom) {
|
||||
QUnit.start();
|
||||
QUnit.module('require.js test');
|
||||
QUnit.test('some normal test', function(assert) {
|
||||
assert.ok(true, "Seeded random created using module:");
|
||||
var check = [];
|
||||
var prng = seedrandom('predictable.');
|
||||
var r;
|
||||
for (var j = 0; j < 5; ++j) {
|
||||
r = prng();
|
||||
assert.ok(true, r + "");
|
||||
check.push(r);
|
||||
}
|
||||
assert.ok(true, "Native random:");
|
||||
for (var j = 0; j < 5; ++j) {
|
||||
r = Math.random();
|
||||
assert.ok(true, r + "");
|
||||
check.push(r);
|
||||
}
|
||||
// Verify against Math.seedrandom.
|
||||
var seed = Math.seedrandom('predictable.');
|
||||
assert.equal(seed, 'predictable.',
|
||||
"Seed should be returned from Math.seedrandom.");
|
||||
for (var j = 0; j < 10; ++j) {
|
||||
r = Math.random();
|
||||
if (j < 5) {
|
||||
assert.equal(check[j], r, "Equal: " + r + " vs " + check[j]);
|
||||
} else {
|
||||
assert.ok(check[j] != r, "Unqual: " + r + " vs " + check[j]);
|
||||
}
|
||||
}
|
||||
document.close();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
5
build/node_modules/seedrandom/test/run_dieharder.sh
generated
vendored
Executable file
5
build/node_modules/seedrandom/test/run_dieharder.sh
generated
vendored
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
# http://www.phy.duke.edu/~rgb/General/dieharder.php
|
||||
# How to run dieharder against seedrandom:
|
||||
|
||||
node bitgen.js | dieharder -g 200 -a | tee out/dieharder-report.txt
|
||||
56
build/node_modules/seedrandom/test/state.html
generated
vendored
Normal file
56
build/node_modules/seedrandom/test/state.html
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="lib/qunit.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="../seedrandom.min.js"></script>
|
||||
<script src="lib/qunit.js"></script>
|
||||
<script>
|
||||
QUnit.module("Options API Test");
|
||||
|
||||
QUnit.test("Verify that state method is not normally present",
|
||||
function(assert) {
|
||||
|
||||
var seedrandom = Math.seedrandom;
|
||||
var dummy = seedrandom('hello');
|
||||
var unexpected = -1;
|
||||
var expected = -1;
|
||||
try {
|
||||
unexpected = dummy.state();
|
||||
} catch(e) {
|
||||
expected = 1;
|
||||
}
|
||||
assert.equal(unexpected, -1);
|
||||
assert.equal(expected, 1);
|
||||
var count = 0;
|
||||
for (var x in dummy) {
|
||||
if (x == 'state') count += 1;
|
||||
}
|
||||
assert.equal(count, 0);
|
||||
|
||||
});
|
||||
|
||||
QUnit.test("Verify that state option works as advertised", function(assert) {
|
||||
|
||||
var seedrandom = Math.seedrandom;
|
||||
var saveable = seedrandom("secret-seed", {state: true});
|
||||
var ordinary = seedrandom("secret-seed");
|
||||
for (var j = 0; j < 1e3; ++j) {
|
||||
assert.equal(ordinary(), saveable());
|
||||
}
|
||||
var virgin = seedrandom("secret-seed");
|
||||
var saved = saveable.state();
|
||||
var replica = seedrandom("", {state: saved});
|
||||
for (var j = 0; j < 1e2; ++j) {
|
||||
var r = replica();
|
||||
assert.equal(r, saveable());
|
||||
assert.equal(r, ordinary());
|
||||
assert.ok(r != virgin());
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user