jspsych 7.2.0 → 7.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.js +117 -967
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +115 -967
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +115 -963
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/src/JsPsych.ts +1 -1
- package/src/index.ts +2 -0
- package/src/modules/randomization.ts +3 -7
package/dist/index.cjs
CHANGED
|
@@ -2,13 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
10
|
-
|
|
11
|
-
/*! *****************************************************************************
|
|
5
|
+
/******************************************************************************
|
|
12
6
|
Copyright (c) Microsoft Corporation.
|
|
13
7
|
|
|
14
8
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -77,7 +71,7 @@ var autoBind = (self, {include, exclude} = {}) => {
|
|
|
77
71
|
return self;
|
|
78
72
|
};
|
|
79
73
|
|
|
80
|
-
var version = "7.2.
|
|
74
|
+
var version = "7.2.3";
|
|
81
75
|
|
|
82
76
|
class MigrationError extends Error {
|
|
83
77
|
constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
|
|
@@ -1634,967 +1628,124 @@ var randomWords$1 = words;
|
|
|
1634
1628
|
// Export the word list as it is often useful
|
|
1635
1629
|
words.wordList = wordList;
|
|
1636
1630
|
|
|
1637
|
-
var alea
|
|
1631
|
+
var alea = {exports: {}};
|
|
1638
1632
|
|
|
1639
1633
|
(function (module) {
|
|
1640
|
-
// A port of an algorithm by Johannes Baagøe <baagoe@baagoe.com>, 2010
|
|
1641
|
-
// http://baagoe.com/en/RandomMusings/javascript/
|
|
1642
|
-
// https://github.com/nquinlan/better-random-numbers-for-javascript-mirror
|
|
1643
|
-
// Original work is under MIT license -
|
|
1644
|
-
|
|
1645
|
-
// Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
|
|
1646
|
-
//
|
|
1647
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1648
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
1649
|
-
// in the Software without restriction, including without limitation the rights
|
|
1650
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1651
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
1652
|
-
// furnished to do so, subject to the following conditions:
|
|
1653
|
-
//
|
|
1654
|
-
// The above copyright notice and this permission notice shall be included in
|
|
1655
|
-
// all copies or substantial portions of the Software.
|
|
1656
|
-
//
|
|
1657
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1658
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1659
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1660
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1661
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1662
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1663
|
-
// THE SOFTWARE.
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
(function(global, module, define) {
|
|
1668
|
-
|
|
1669
|
-
function Alea(seed) {
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
function copy(f, t) {
|
|
1694
|
-
t.c = f.c;
|
|
1695
|
-
t.s0 = f.s0;
|
|
1696
|
-
t.s1 = f.s1;
|
|
1697
|
-
t.s2 = f.s2;
|
|
1698
|
-
return t;
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
function impl(seed, opts) {
|
|
1702
|
-
var xg = new Alea(seed),
|
|
1703
|
-
state = opts && opts.state,
|
|
1704
|
-
prng = xg.next;
|
|
1705
|
-
prng.int32 = function() { return (xg.next() * 0x100000000) | 0; };
|
|
1706
|
-
prng.double = function() {
|
|
1707
|
-
return prng() + (prng() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
|
|
1708
|
-
};
|
|
1709
|
-
prng.quick = prng;
|
|
1710
|
-
if (state) {
|
|
1711
|
-
if (typeof(state) == 'object') copy(state, xg);
|
|
1712
|
-
prng.state = function() { return copy(xg, {}); };
|
|
1713
|
-
}
|
|
1714
|
-
return prng;
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1717
|
-
function Mash() {
|
|
1718
|
-
var n = 0xefc8249d;
|
|
1719
|
-
|
|
1720
|
-
var mash = function(data) {
|
|
1721
|
-
data = String(data);
|
|
1722
|
-
for (var i = 0; i < data.length; i++) {
|
|
1723
|
-
n += data.charCodeAt(i);
|
|
1724
|
-
var h = 0.02519603282416938 * n;
|
|
1725
|
-
n = h >>> 0;
|
|
1726
|
-
h -= n;
|
|
1727
|
-
h *= n;
|
|
1728
|
-
n = h >>> 0;
|
|
1729
|
-
h -= n;
|
|
1730
|
-
n += h * 0x100000000; // 2^32
|
|
1731
|
-
}
|
|
1732
|
-
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
|
|
1733
|
-
};
|
|
1734
|
-
|
|
1735
|
-
return mash;
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
if (module && module.exports) {
|
|
1740
|
-
module.exports = impl;
|
|
1741
|
-
} else if (define && define.amd) {
|
|
1742
|
-
define(function() { return impl; });
|
|
1743
|
-
} else {
|
|
1744
|
-
this.alea = impl;
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
})(
|
|
1748
|
-
commonjsGlobal,
|
|
1749
|
-
module, // present in node.js
|
|
1750
|
-
(typeof undefined) == 'function' // present with an AMD loader
|
|
1751
|
-
);
|
|
1752
|
-
}(alea$1));
|
|
1753
|
-
|
|
1754
|
-
var xor128$1 = {exports: {}};
|
|
1755
|
-
|
|
1756
|
-
(function (module) {
|
|
1757
|
-
// A Javascript implementaion of the "xor128" prng algorithm by
|
|
1758
|
-
// George Marsaglia. See http://www.jstatsoft.org/v08/i14/paper
|
|
1759
|
-
|
|
1760
|
-
(function(global, module, define) {
|
|
1761
|
-
|
|
1762
|
-
function XorGen(seed) {
|
|
1763
|
-
var me = this, strseed = '';
|
|
1764
|
-
|
|
1765
|
-
me.x = 0;
|
|
1766
|
-
me.y = 0;
|
|
1767
|
-
me.z = 0;
|
|
1768
|
-
me.w = 0;
|
|
1769
|
-
|
|
1770
|
-
// Set up generator function.
|
|
1771
|
-
me.next = function() {
|
|
1772
|
-
var t = me.x ^ (me.x << 11);
|
|
1773
|
-
me.x = me.y;
|
|
1774
|
-
me.y = me.z;
|
|
1775
|
-
me.z = me.w;
|
|
1776
|
-
return me.w ^= (me.w >>> 19) ^ t ^ (t >>> 8);
|
|
1777
|
-
};
|
|
1778
|
-
|
|
1779
|
-
if (seed === (seed | 0)) {
|
|
1780
|
-
// Integer seed.
|
|
1781
|
-
me.x = seed;
|
|
1782
|
-
} else {
|
|
1783
|
-
// String seed.
|
|
1784
|
-
strseed += seed;
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
// Mix in string seed, then discard an initial batch of 64 values.
|
|
1788
|
-
for (var k = 0; k < strseed.length + 64; k++) {
|
|
1789
|
-
me.x ^= strseed.charCodeAt(k) | 0;
|
|
1790
|
-
me.next();
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
|
-
function copy(f, t) {
|
|
1795
|
-
t.x = f.x;
|
|
1796
|
-
t.y = f.y;
|
|
1797
|
-
t.z = f.z;
|
|
1798
|
-
t.w = f.w;
|
|
1799
|
-
return t;
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
function impl(seed, opts) {
|
|
1803
|
-
var xg = new XorGen(seed),
|
|
1804
|
-
state = opts && opts.state,
|
|
1805
|
-
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
|
1806
|
-
prng.double = function() {
|
|
1807
|
-
do {
|
|
1808
|
-
var top = xg.next() >>> 11,
|
|
1809
|
-
bot = (xg.next() >>> 0) / 0x100000000,
|
|
1810
|
-
result = (top + bot) / (1 << 21);
|
|
1811
|
-
} while (result === 0);
|
|
1812
|
-
return result;
|
|
1813
|
-
};
|
|
1814
|
-
prng.int32 = xg.next;
|
|
1815
|
-
prng.quick = prng;
|
|
1816
|
-
if (state) {
|
|
1817
|
-
if (typeof(state) == 'object') copy(state, xg);
|
|
1818
|
-
prng.state = function() { return copy(xg, {}); };
|
|
1819
|
-
}
|
|
1820
|
-
return prng;
|
|
1821
|
-
}
|
|
1822
|
-
|
|
1823
|
-
if (module && module.exports) {
|
|
1824
|
-
module.exports = impl;
|
|
1825
|
-
} else if (define && define.amd) {
|
|
1826
|
-
define(function() { return impl; });
|
|
1827
|
-
} else {
|
|
1828
|
-
this.xor128 = impl;
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
})(
|
|
1832
|
-
commonjsGlobal,
|
|
1833
|
-
module, // present in node.js
|
|
1834
|
-
(typeof undefined) == 'function' // present with an AMD loader
|
|
1835
|
-
);
|
|
1836
|
-
}(xor128$1));
|
|
1837
|
-
|
|
1838
|
-
var xorwow$1 = {exports: {}};
|
|
1839
|
-
|
|
1840
|
-
(function (module) {
|
|
1841
|
-
// A Javascript implementaion of the "xorwow" prng algorithm by
|
|
1842
|
-
// George Marsaglia. See http://www.jstatsoft.org/v08/i14/paper
|
|
1843
|
-
|
|
1844
|
-
(function(global, module, define) {
|
|
1845
|
-
|
|
1846
|
-
function XorGen(seed) {
|
|
1847
|
-
var me = this, strseed = '';
|
|
1848
|
-
|
|
1849
|
-
// Set up generator function.
|
|
1850
|
-
me.next = function() {
|
|
1851
|
-
var t = (me.x ^ (me.x >>> 2));
|
|
1852
|
-
me.x = me.y; me.y = me.z; me.z = me.w; me.w = me.v;
|
|
1853
|
-
return (me.d = (me.d + 362437 | 0)) +
|
|
1854
|
-
(me.v = (me.v ^ (me.v << 4)) ^ (t ^ (t << 1))) | 0;
|
|
1855
|
-
};
|
|
1856
|
-
|
|
1857
|
-
me.x = 0;
|
|
1858
|
-
me.y = 0;
|
|
1859
|
-
me.z = 0;
|
|
1860
|
-
me.w = 0;
|
|
1861
|
-
me.v = 0;
|
|
1862
|
-
|
|
1863
|
-
if (seed === (seed | 0)) {
|
|
1864
|
-
// Integer seed.
|
|
1865
|
-
me.x = seed;
|
|
1866
|
-
} else {
|
|
1867
|
-
// String seed.
|
|
1868
|
-
strseed += seed;
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
|
-
// Mix in string seed, then discard an initial batch of 64 values.
|
|
1872
|
-
for (var k = 0; k < strseed.length + 64; k++) {
|
|
1873
|
-
me.x ^= strseed.charCodeAt(k) | 0;
|
|
1874
|
-
if (k == strseed.length) {
|
|
1875
|
-
me.d = me.x << 10 ^ me.x >>> 4;
|
|
1876
|
-
}
|
|
1877
|
-
me.next();
|
|
1878
|
-
}
|
|
1879
|
-
}
|
|
1880
|
-
|
|
1881
|
-
function copy(f, t) {
|
|
1882
|
-
t.x = f.x;
|
|
1883
|
-
t.y = f.y;
|
|
1884
|
-
t.z = f.z;
|
|
1885
|
-
t.w = f.w;
|
|
1886
|
-
t.v = f.v;
|
|
1887
|
-
t.d = f.d;
|
|
1888
|
-
return t;
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
function impl(seed, opts) {
|
|
1892
|
-
var xg = new XorGen(seed),
|
|
1893
|
-
state = opts && opts.state,
|
|
1894
|
-
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
|
1895
|
-
prng.double = function() {
|
|
1896
|
-
do {
|
|
1897
|
-
var top = xg.next() >>> 11,
|
|
1898
|
-
bot = (xg.next() >>> 0) / 0x100000000,
|
|
1899
|
-
result = (top + bot) / (1 << 21);
|
|
1900
|
-
} while (result === 0);
|
|
1901
|
-
return result;
|
|
1902
|
-
};
|
|
1903
|
-
prng.int32 = xg.next;
|
|
1904
|
-
prng.quick = prng;
|
|
1905
|
-
if (state) {
|
|
1906
|
-
if (typeof(state) == 'object') copy(state, xg);
|
|
1907
|
-
prng.state = function() { return copy(xg, {}); };
|
|
1908
|
-
}
|
|
1909
|
-
return prng;
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
if (module && module.exports) {
|
|
1913
|
-
module.exports = impl;
|
|
1914
|
-
} else if (define && define.amd) {
|
|
1915
|
-
define(function() { return impl; });
|
|
1916
|
-
} else {
|
|
1917
|
-
this.xorwow = impl;
|
|
1918
|
-
}
|
|
1919
|
-
|
|
1920
|
-
})(
|
|
1921
|
-
commonjsGlobal,
|
|
1922
|
-
module, // present in node.js
|
|
1923
|
-
(typeof undefined) == 'function' // present with an AMD loader
|
|
1924
|
-
);
|
|
1925
|
-
}(xorwow$1));
|
|
1926
|
-
|
|
1927
|
-
var xorshift7$1 = {exports: {}};
|
|
1928
|
-
|
|
1929
|
-
(function (module) {
|
|
1930
|
-
// A Javascript implementaion of the "xorshift7" algorithm by
|
|
1931
|
-
// François Panneton and Pierre L'ecuyer:
|
|
1932
|
-
// "On the Xorgshift Random Number Generators"
|
|
1933
|
-
// http://saluc.engr.uconn.edu/refs/crypto/rng/panneton05onthexorshift.pdf
|
|
1934
|
-
|
|
1935
|
-
(function(global, module, define) {
|
|
1936
|
-
|
|
1937
|
-
function XorGen(seed) {
|
|
1938
|
-
var me = this;
|
|
1939
|
-
|
|
1940
|
-
// Set up generator function.
|
|
1941
|
-
me.next = function() {
|
|
1942
|
-
// Update xor generator.
|
|
1943
|
-
var X = me.x, i = me.i, t, v;
|
|
1944
|
-
t = X[i]; t ^= (t >>> 7); v = t ^ (t << 24);
|
|
1945
|
-
t = X[(i + 1) & 7]; v ^= t ^ (t >>> 10);
|
|
1946
|
-
t = X[(i + 3) & 7]; v ^= t ^ (t >>> 3);
|
|
1947
|
-
t = X[(i + 4) & 7]; v ^= t ^ (t << 7);
|
|
1948
|
-
t = X[(i + 7) & 7]; t = t ^ (t << 13); v ^= t ^ (t << 9);
|
|
1949
|
-
X[i] = v;
|
|
1950
|
-
me.i = (i + 1) & 7;
|
|
1951
|
-
return v;
|
|
1952
|
-
};
|
|
1953
|
-
|
|
1954
|
-
function init(me, seed) {
|
|
1955
|
-
var j, X = [];
|
|
1956
|
-
|
|
1957
|
-
if (seed === (seed | 0)) {
|
|
1958
|
-
// Seed state array using a 32-bit integer.
|
|
1959
|
-
X[0] = seed;
|
|
1960
|
-
} else {
|
|
1961
|
-
// Seed state using a string.
|
|
1962
|
-
seed = '' + seed;
|
|
1963
|
-
for (j = 0; j < seed.length; ++j) {
|
|
1964
|
-
X[j & 7] = (X[j & 7] << 15) ^
|
|
1965
|
-
(seed.charCodeAt(j) + X[(j + 1) & 7] << 13);
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
// Enforce an array length of 8, not all zeroes.
|
|
1969
|
-
while (X.length < 8) X.push(0);
|
|
1970
|
-
for (j = 0; j < 8 && X[j] === 0; ++j);
|
|
1971
|
-
if (j == 8) X[7] = -1;
|
|
1972
|
-
|
|
1973
|
-
me.x = X;
|
|
1974
|
-
me.i = 0;
|
|
1975
|
-
|
|
1976
|
-
// Discard an initial 256 values.
|
|
1977
|
-
for (j = 256; j > 0; --j) {
|
|
1978
|
-
me.next();
|
|
1979
|
-
}
|
|
1980
|
-
}
|
|
1981
|
-
|
|
1982
|
-
init(me, seed);
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
function copy(f, t) {
|
|
1986
|
-
t.x = f.x.slice();
|
|
1987
|
-
t.i = f.i;
|
|
1988
|
-
return t;
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
function impl(seed, opts) {
|
|
1992
|
-
if (seed == null) seed = +(new Date);
|
|
1993
|
-
var xg = new XorGen(seed),
|
|
1994
|
-
state = opts && opts.state,
|
|
1995
|
-
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
|
1996
|
-
prng.double = function() {
|
|
1997
|
-
do {
|
|
1998
|
-
var top = xg.next() >>> 11,
|
|
1999
|
-
bot = (xg.next() >>> 0) / 0x100000000,
|
|
2000
|
-
result = (top + bot) / (1 << 21);
|
|
2001
|
-
} while (result === 0);
|
|
2002
|
-
return result;
|
|
2003
|
-
};
|
|
2004
|
-
prng.int32 = xg.next;
|
|
2005
|
-
prng.quick = prng;
|
|
2006
|
-
if (state) {
|
|
2007
|
-
if (state.x) copy(state, xg);
|
|
2008
|
-
prng.state = function() { return copy(xg, {}); };
|
|
2009
|
-
}
|
|
2010
|
-
return prng;
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
if (module && module.exports) {
|
|
2014
|
-
module.exports = impl;
|
|
2015
|
-
} else if (define && define.amd) {
|
|
2016
|
-
define(function() { return impl; });
|
|
2017
|
-
} else {
|
|
2018
|
-
this.xorshift7 = impl;
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
})(
|
|
2022
|
-
commonjsGlobal,
|
|
2023
|
-
module, // present in node.js
|
|
2024
|
-
(typeof undefined) == 'function' // present with an AMD loader
|
|
2025
|
-
);
|
|
2026
|
-
}(xorshift7$1));
|
|
2027
|
-
|
|
2028
|
-
var xor4096$1 = {exports: {}};
|
|
2029
|
-
|
|
2030
|
-
(function (module) {
|
|
2031
|
-
// A Javascript implementaion of Richard Brent's Xorgens xor4096 algorithm.
|
|
2032
|
-
//
|
|
2033
|
-
// This fast non-cryptographic random number generator is designed for
|
|
2034
|
-
// use in Monte-Carlo algorithms. It combines a long-period xorshift
|
|
2035
|
-
// generator with a Weyl generator, and it passes all common batteries
|
|
2036
|
-
// of stasticial tests for randomness while consuming only a few nanoseconds
|
|
2037
|
-
// for each prng generated. For background on the generator, see Brent's
|
|
2038
|
-
// paper: "Some long-period random number generators using shifts and xors."
|
|
2039
|
-
// http://arxiv.org/pdf/1004.3115v1.pdf
|
|
2040
|
-
//
|
|
2041
|
-
// Usage:
|
|
2042
|
-
//
|
|
2043
|
-
// var xor4096 = require('xor4096');
|
|
2044
|
-
// random = xor4096(1); // Seed with int32 or string.
|
|
2045
|
-
// assert.equal(random(), 0.1520436450538547); // (0, 1) range, 53 bits.
|
|
2046
|
-
// assert.equal(random.int32(), 1806534897); // signed int32, 32 bits.
|
|
2047
|
-
//
|
|
2048
|
-
// For nonzero numeric keys, this impelementation provides a sequence
|
|
2049
|
-
// identical to that by Brent's xorgens 3 implementaion in C. This
|
|
2050
|
-
// implementation also provides for initalizing the generator with
|
|
2051
|
-
// string seeds, or for saving and restoring the state of the generator.
|
|
2052
|
-
//
|
|
2053
|
-
// On Chrome, this prng benchmarks about 2.1 times slower than
|
|
2054
|
-
// Javascript's built-in Math.random().
|
|
2055
|
-
|
|
2056
|
-
(function(global, module, define) {
|
|
2057
|
-
|
|
2058
|
-
function XorGen(seed) {
|
|
2059
|
-
var me = this;
|
|
2060
|
-
|
|
2061
|
-
// Set up generator function.
|
|
2062
|
-
me.next = function() {
|
|
2063
|
-
var w = me.w,
|
|
2064
|
-
X = me.X, i = me.i, t, v;
|
|
2065
|
-
// Update Weyl generator.
|
|
2066
|
-
me.w = w = (w + 0x61c88647) | 0;
|
|
2067
|
-
// Update xor generator.
|
|
2068
|
-
v = X[(i + 34) & 127];
|
|
2069
|
-
t = X[i = ((i + 1) & 127)];
|
|
2070
|
-
v ^= v << 13;
|
|
2071
|
-
t ^= t << 17;
|
|
2072
|
-
v ^= v >>> 15;
|
|
2073
|
-
t ^= t >>> 12;
|
|
2074
|
-
// Update Xor generator array state.
|
|
2075
|
-
v = X[i] = v ^ t;
|
|
2076
|
-
me.i = i;
|
|
2077
|
-
// Result is the combination.
|
|
2078
|
-
return (v + (w ^ (w >>> 16))) | 0;
|
|
2079
|
-
};
|
|
2080
|
-
|
|
2081
|
-
function init(me, seed) {
|
|
2082
|
-
var t, v, i, j, w, X = [], limit = 128;
|
|
2083
|
-
if (seed === (seed | 0)) {
|
|
2084
|
-
// Numeric seeds initialize v, which is used to generates X.
|
|
2085
|
-
v = seed;
|
|
2086
|
-
seed = null;
|
|
2087
|
-
} else {
|
|
2088
|
-
// String seeds are mixed into v and X one character at a time.
|
|
2089
|
-
seed = seed + '\0';
|
|
2090
|
-
v = 0;
|
|
2091
|
-
limit = Math.max(limit, seed.length);
|
|
2092
|
-
}
|
|
2093
|
-
// Initialize circular array and weyl value.
|
|
2094
|
-
for (i = 0, j = -32; j < limit; ++j) {
|
|
2095
|
-
// Put the unicode characters into the array, and shuffle them.
|
|
2096
|
-
if (seed) v ^= seed.charCodeAt((j + 32) % seed.length);
|
|
2097
|
-
// After 32 shuffles, take v as the starting w value.
|
|
2098
|
-
if (j === 0) w = v;
|
|
2099
|
-
v ^= v << 10;
|
|
2100
|
-
v ^= v >>> 15;
|
|
2101
|
-
v ^= v << 4;
|
|
2102
|
-
v ^= v >>> 13;
|
|
2103
|
-
if (j >= 0) {
|
|
2104
|
-
w = (w + 0x61c88647) | 0; // Weyl.
|
|
2105
|
-
t = (X[j & 127] ^= (v + w)); // Combine xor and weyl to init array.
|
|
2106
|
-
i = (0 == t) ? i + 1 : 0; // Count zeroes.
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
|
-
// We have detected all zeroes; make the key nonzero.
|
|
2110
|
-
if (i >= 128) {
|
|
2111
|
-
X[(seed && seed.length || 0) & 127] = -1;
|
|
2112
|
-
}
|
|
2113
|
-
// Run the generator 512 times to further mix the state before using it.
|
|
2114
|
-
// Factoring this as a function slows the main generator, so it is just
|
|
2115
|
-
// unrolled here. The weyl generator is not advanced while warming up.
|
|
2116
|
-
i = 127;
|
|
2117
|
-
for (j = 4 * 128; j > 0; --j) {
|
|
2118
|
-
v = X[(i + 34) & 127];
|
|
2119
|
-
t = X[i = ((i + 1) & 127)];
|
|
2120
|
-
v ^= v << 13;
|
|
2121
|
-
t ^= t << 17;
|
|
2122
|
-
v ^= v >>> 15;
|
|
2123
|
-
t ^= t >>> 12;
|
|
2124
|
-
X[i] = v ^ t;
|
|
2125
|
-
}
|
|
2126
|
-
// Storing state as object members is faster than using closure variables.
|
|
2127
|
-
me.w = w;
|
|
2128
|
-
me.X = X;
|
|
2129
|
-
me.i = i;
|
|
2130
|
-
}
|
|
2131
|
-
|
|
2132
|
-
init(me, seed);
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
function copy(f, t) {
|
|
2136
|
-
t.i = f.i;
|
|
2137
|
-
t.w = f.w;
|
|
2138
|
-
t.X = f.X.slice();
|
|
2139
|
-
return t;
|
|
2140
|
-
}
|
|
2141
|
-
function impl(seed, opts) {
|
|
2142
|
-
if (seed == null) seed = +(new Date);
|
|
2143
|
-
var xg = new XorGen(seed),
|
|
2144
|
-
state = opts && opts.state,
|
|
2145
|
-
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
|
2146
|
-
prng.double = function() {
|
|
2147
|
-
do {
|
|
2148
|
-
var top = xg.next() >>> 11,
|
|
2149
|
-
bot = (xg.next() >>> 0) / 0x100000000,
|
|
2150
|
-
result = (top + bot) / (1 << 21);
|
|
2151
|
-
} while (result === 0);
|
|
2152
|
-
return result;
|
|
2153
|
-
};
|
|
2154
|
-
prng.int32 = xg.next;
|
|
2155
|
-
prng.quick = prng;
|
|
2156
|
-
if (state) {
|
|
2157
|
-
if (state.X) copy(state, xg);
|
|
2158
|
-
prng.state = function() { return copy(xg, {}); };
|
|
2159
|
-
}
|
|
2160
|
-
return prng;
|
|
2161
|
-
}
|
|
2162
|
-
|
|
2163
|
-
if (module && module.exports) {
|
|
2164
|
-
module.exports = impl;
|
|
2165
|
-
} else if (define && define.amd) {
|
|
2166
|
-
define(function() { return impl; });
|
|
2167
|
-
} else {
|
|
2168
|
-
this.xor4096 = impl;
|
|
2169
|
-
}
|
|
2170
|
-
|
|
2171
|
-
})(
|
|
2172
|
-
commonjsGlobal, // window object or global
|
|
2173
|
-
module, // present in node.js
|
|
2174
|
-
(typeof undefined) == 'function' // present with an AMD loader
|
|
2175
|
-
);
|
|
2176
|
-
}(xor4096$1));
|
|
2177
|
-
|
|
2178
|
-
var tychei$1 = {exports: {}};
|
|
2179
|
-
|
|
2180
|
-
(function (module) {
|
|
2181
|
-
// A Javascript implementaion of the "Tyche-i" prng algorithm by
|
|
2182
|
-
// Samuel Neves and Filipe Araujo.
|
|
2183
|
-
// See https://eden.dei.uc.pt/~sneves/pubs/2011-snfa2.pdf
|
|
2184
|
-
|
|
2185
|
-
(function(global, module, define) {
|
|
2186
|
-
|
|
2187
|
-
function XorGen(seed) {
|
|
2188
|
-
var me = this, strseed = '';
|
|
2189
|
-
|
|
2190
|
-
// Set up generator function.
|
|
2191
|
-
me.next = function() {
|
|
2192
|
-
var b = me.b, c = me.c, d = me.d, a = me.a;
|
|
2193
|
-
b = (b << 25) ^ (b >>> 7) ^ c;
|
|
2194
|
-
c = (c - d) | 0;
|
|
2195
|
-
d = (d << 24) ^ (d >>> 8) ^ a;
|
|
2196
|
-
a = (a - b) | 0;
|
|
2197
|
-
me.b = b = (b << 20) ^ (b >>> 12) ^ c;
|
|
2198
|
-
me.c = c = (c - d) | 0;
|
|
2199
|
-
me.d = (d << 16) ^ (c >>> 16) ^ a;
|
|
2200
|
-
return me.a = (a - b) | 0;
|
|
2201
|
-
};
|
|
2202
|
-
|
|
2203
|
-
/* The following is non-inverted tyche, which has better internal
|
|
2204
|
-
* bit diffusion, but which is about 25% slower than tyche-i in JS.
|
|
2205
|
-
me.next = function() {
|
|
2206
|
-
var a = me.a, b = me.b, c = me.c, d = me.d;
|
|
2207
|
-
a = (me.a + me.b | 0) >>> 0;
|
|
2208
|
-
d = me.d ^ a; d = d << 16 ^ d >>> 16;
|
|
2209
|
-
c = me.c + d | 0;
|
|
2210
|
-
b = me.b ^ c; b = b << 12 ^ d >>> 20;
|
|
2211
|
-
me.a = a = a + b | 0;
|
|
2212
|
-
d = d ^ a; me.d = d = d << 8 ^ d >>> 24;
|
|
2213
|
-
me.c = c = c + d | 0;
|
|
2214
|
-
b = b ^ c;
|
|
2215
|
-
return me.b = (b << 7 ^ b >>> 25);
|
|
2216
|
-
}
|
|
2217
|
-
*/
|
|
2218
|
-
|
|
2219
|
-
me.a = 0;
|
|
2220
|
-
me.b = 0;
|
|
2221
|
-
me.c = 2654435769 | 0;
|
|
2222
|
-
me.d = 1367130551;
|
|
2223
|
-
|
|
2224
|
-
if (seed === Math.floor(seed)) {
|
|
2225
|
-
// Integer seed.
|
|
2226
|
-
me.a = (seed / 0x100000000) | 0;
|
|
2227
|
-
me.b = seed | 0;
|
|
2228
|
-
} else {
|
|
2229
|
-
// String seed.
|
|
2230
|
-
strseed += seed;
|
|
2231
|
-
}
|
|
2232
|
-
|
|
2233
|
-
// Mix in string seed, then discard an initial batch of 64 values.
|
|
2234
|
-
for (var k = 0; k < strseed.length + 20; k++) {
|
|
2235
|
-
me.b ^= strseed.charCodeAt(k) | 0;
|
|
2236
|
-
me.next();
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
|
-
function copy(f, t) {
|
|
2241
|
-
t.a = f.a;
|
|
2242
|
-
t.b = f.b;
|
|
2243
|
-
t.c = f.c;
|
|
2244
|
-
t.d = f.d;
|
|
2245
|
-
return t;
|
|
2246
|
-
}
|
|
2247
|
-
function impl(seed, opts) {
|
|
2248
|
-
var xg = new XorGen(seed),
|
|
2249
|
-
state = opts && opts.state,
|
|
2250
|
-
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
|
2251
|
-
prng.double = function() {
|
|
2252
|
-
do {
|
|
2253
|
-
var top = xg.next() >>> 11,
|
|
2254
|
-
bot = (xg.next() >>> 0) / 0x100000000,
|
|
2255
|
-
result = (top + bot) / (1 << 21);
|
|
2256
|
-
} while (result === 0);
|
|
2257
|
-
return result;
|
|
2258
|
-
};
|
|
2259
|
-
prng.int32 = xg.next;
|
|
2260
|
-
prng.quick = prng;
|
|
2261
|
-
if (state) {
|
|
2262
|
-
if (typeof(state) == 'object') copy(state, xg);
|
|
2263
|
-
prng.state = function() { return copy(xg, {}); };
|
|
2264
|
-
}
|
|
2265
|
-
return prng;
|
|
2266
|
-
}
|
|
2267
|
-
|
|
2268
|
-
if (module && module.exports) {
|
|
2269
|
-
module.exports = impl;
|
|
2270
|
-
} else if (define && define.amd) {
|
|
2271
|
-
define(function() { return impl; });
|
|
2272
|
-
} else {
|
|
2273
|
-
this.tychei = impl;
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
|
-
})(
|
|
2277
|
-
commonjsGlobal,
|
|
2278
|
-
module, // present in node.js
|
|
2279
|
-
(typeof undefined) == 'function' // present with an AMD loader
|
|
2280
|
-
);
|
|
2281
|
-
}(tychei$1));
|
|
2282
|
-
|
|
2283
|
-
var seedrandom$1 = {exports: {}};
|
|
2284
|
-
|
|
2285
|
-
/*
|
|
2286
|
-
Copyright 2019 David Bau.
|
|
2287
|
-
|
|
2288
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
2289
|
-
a copy of this software and associated documentation files (the
|
|
2290
|
-
"Software"), to deal in the Software without restriction, including
|
|
2291
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
2292
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
2293
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
2294
|
-
the following conditions:
|
|
2295
|
-
|
|
2296
|
-
The above copyright notice and this permission notice shall be
|
|
2297
|
-
included in all copies or substantial portions of the Software.
|
|
2298
|
-
|
|
2299
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
2300
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
2301
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
2302
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
2303
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
2304
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
2305
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2306
|
-
|
|
2307
|
-
*/
|
|
2308
|
-
|
|
2309
|
-
(function (module) {
|
|
2310
|
-
(function (global, pool, math) {
|
|
2311
|
-
//
|
|
2312
|
-
// The following constants are related to IEEE 754 limits.
|
|
2313
|
-
//
|
|
2314
|
-
|
|
2315
|
-
var width = 256, // each RC4 output is 0 <= x < 256
|
|
2316
|
-
chunks = 6, // at least six RC4 outputs for each double
|
|
2317
|
-
digits = 52, // there are 52 significant digits in a double
|
|
2318
|
-
rngname = 'random', // rngname: name for Math.random and Math.seedrandom
|
|
2319
|
-
startdenom = math.pow(width, chunks),
|
|
2320
|
-
significance = math.pow(2, digits),
|
|
2321
|
-
overflow = significance * 2,
|
|
2322
|
-
mask = width - 1,
|
|
2323
|
-
nodecrypto; // node.js crypto module, initialized at the bottom.
|
|
2324
|
-
|
|
2325
|
-
//
|
|
2326
|
-
// seedrandom()
|
|
2327
|
-
// This is the seedrandom function described above.
|
|
2328
|
-
//
|
|
2329
|
-
function seedrandom(seed, options, callback) {
|
|
2330
|
-
var key = [];
|
|
2331
|
-
options = (options == true) ? { entropy: true } : (options || {});
|
|
2332
|
-
|
|
2333
|
-
// Flatten the seed string or build one from local entropy if needed.
|
|
2334
|
-
var shortseed = mixkey(flatten(
|
|
2335
|
-
options.entropy ? [seed, tostring(pool)] :
|
|
2336
|
-
(seed == null) ? autoseed() : seed, 3), key);
|
|
2337
|
-
|
|
2338
|
-
// Use the seed to initialize an ARC4 generator.
|
|
2339
|
-
var arc4 = new ARC4(key);
|
|
2340
|
-
|
|
2341
|
-
// This function returns a random double in [0, 1) that contains
|
|
2342
|
-
// randomness in every bit of the mantissa of the IEEE 754 value.
|
|
2343
|
-
var prng = function() {
|
|
2344
|
-
var n = arc4.g(chunks), // Start with a numerator n < 2 ^ 48
|
|
2345
|
-
d = startdenom, // and denominator d = 2 ^ 48.
|
|
2346
|
-
x = 0; // and no 'extra last byte'.
|
|
2347
|
-
while (n < significance) { // Fill up all significant digits by
|
|
2348
|
-
n = (n + x) * width; // shifting numerator and
|
|
2349
|
-
d *= width; // denominator and generating a
|
|
2350
|
-
x = arc4.g(1); // new least-significant-byte.
|
|
2351
|
-
}
|
|
2352
|
-
while (n >= overflow) { // To avoid rounding up, before adding
|
|
2353
|
-
n /= 2; // last byte, shift everything
|
|
2354
|
-
d /= 2; // right using integer math until
|
|
2355
|
-
x >>>= 1; // we have exactly the desired bits.
|
|
2356
|
-
}
|
|
2357
|
-
return (n + x) / d; // Form the number within [0, 1).
|
|
2358
|
-
};
|
|
2359
|
-
|
|
2360
|
-
prng.int32 = function() { return arc4.g(4) | 0; };
|
|
2361
|
-
prng.quick = function() { return arc4.g(4) / 0x100000000; };
|
|
2362
|
-
prng.double = prng;
|
|
2363
|
-
|
|
2364
|
-
// Mix the randomness into accumulated entropy.
|
|
2365
|
-
mixkey(tostring(arc4.S), pool);
|
|
2366
|
-
|
|
2367
|
-
// Calling convention: what to return as a function of prng, seed, is_math.
|
|
2368
|
-
return (options.pass || callback ||
|
|
2369
|
-
function(prng, seed, is_math_call, state) {
|
|
2370
|
-
if (state) {
|
|
2371
|
-
// Load the arc4 state from the given state if it has an S array.
|
|
2372
|
-
if (state.S) { copy(state, arc4); }
|
|
2373
|
-
// Only provide the .state method if requested via options.state.
|
|
2374
|
-
prng.state = function() { return copy(arc4, {}); };
|
|
2375
|
-
}
|
|
2376
|
-
|
|
2377
|
-
// If called as a method of Math (Math.seedrandom()), mutate
|
|
2378
|
-
// Math.random because that is how seedrandom.js has worked since v1.0.
|
|
2379
|
-
if (is_math_call) { math[rngname] = prng; return seed; }
|
|
2380
|
-
|
|
2381
|
-
// Otherwise, it is a newer calling convention, so return the
|
|
2382
|
-
// prng directly.
|
|
2383
|
-
else return prng;
|
|
2384
|
-
})(
|
|
2385
|
-
prng,
|
|
2386
|
-
shortseed,
|
|
2387
|
-
'global' in options ? options.global : (this == math),
|
|
2388
|
-
options.state);
|
|
2389
|
-
}
|
|
2390
|
-
|
|
2391
|
-
//
|
|
2392
|
-
// ARC4
|
|
2393
|
-
//
|
|
2394
|
-
// An ARC4 implementation. The constructor takes a key in the form of
|
|
2395
|
-
// an array of at most (width) integers that should be 0 <= x < (width).
|
|
2396
|
-
//
|
|
2397
|
-
// The g(count) method returns a pseudorandom integer that concatenates
|
|
2398
|
-
// the next (count) outputs from ARC4. Its return value is a number x
|
|
2399
|
-
// that is in the range 0 <= x < (width ^ count).
|
|
2400
|
-
//
|
|
2401
|
-
function ARC4(key) {
|
|
2402
|
-
var t, keylen = key.length,
|
|
2403
|
-
me = this, i = 0, j = me.i = me.j = 0, s = me.S = [];
|
|
2404
|
-
|
|
2405
|
-
// The empty key [] is treated as [0].
|
|
2406
|
-
if (!keylen) { key = [keylen++]; }
|
|
2407
|
-
|
|
2408
|
-
// Set up S using the standard key scheduling algorithm.
|
|
2409
|
-
while (i < width) {
|
|
2410
|
-
s[i] = i++;
|
|
2411
|
-
}
|
|
2412
|
-
for (i = 0; i < width; i++) {
|
|
2413
|
-
s[i] = s[j = mask & (j + key[i % keylen] + (t = s[i]))];
|
|
2414
|
-
s[j] = t;
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
// The "g" method returns the next (count) outputs as one number.
|
|
2418
|
-
(me.g = function(count) {
|
|
2419
|
-
// Using instance members instead of closure state nearly doubles speed.
|
|
2420
|
-
var t, r = 0,
|
|
2421
|
-
i = me.i, j = me.j, s = me.S;
|
|
2422
|
-
while (count--) {
|
|
2423
|
-
t = s[i = mask & (i + 1)];
|
|
2424
|
-
r = r * width + s[mask & ((s[i] = s[j = mask & (j + t)]) + (s[j] = t))];
|
|
2425
|
-
}
|
|
2426
|
-
me.i = i; me.j = j;
|
|
2427
|
-
return r;
|
|
2428
|
-
// For robust unpredictability, the function call below automatically
|
|
2429
|
-
// discards an initial batch of values. This is called RC4-drop[256].
|
|
2430
|
-
// See http://google.com/search?q=rsa+fluhrer+response&btnI
|
|
2431
|
-
})(width);
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
//
|
|
2435
|
-
// copy()
|
|
2436
|
-
// Copies internal state of ARC4 to or from a plain object.
|
|
2437
|
-
//
|
|
2438
|
-
function copy(f, t) {
|
|
2439
|
-
t.i = f.i;
|
|
2440
|
-
t.j = f.j;
|
|
2441
|
-
t.S = f.S.slice();
|
|
2442
|
-
return t;
|
|
2443
|
-
}
|
|
2444
|
-
//
|
|
2445
|
-
// flatten()
|
|
2446
|
-
// Converts an object tree to nested arrays of strings.
|
|
2447
|
-
//
|
|
2448
|
-
function flatten(obj, depth) {
|
|
2449
|
-
var result = [], typ = (typeof obj), prop;
|
|
2450
|
-
if (depth && typ == 'object') {
|
|
2451
|
-
for (prop in obj) {
|
|
2452
|
-
try { result.push(flatten(obj[prop], depth - 1)); } catch (e) {}
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2455
|
-
return (result.length ? result : typ == 'string' ? obj : obj + '\0');
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
//
|
|
2459
|
-
// mixkey()
|
|
2460
|
-
// Mixes a string seed into a key that is an array of integers, and
|
|
2461
|
-
// returns a shortened string seed that is equivalent to the result key.
|
|
2462
|
-
//
|
|
2463
|
-
function mixkey(seed, key) {
|
|
2464
|
-
var stringseed = seed + '', smear, j = 0;
|
|
2465
|
-
while (j < stringseed.length) {
|
|
2466
|
-
key[mask & j] =
|
|
2467
|
-
mask & ((smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++));
|
|
2468
|
-
}
|
|
2469
|
-
return tostring(key);
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2472
|
-
//
|
|
2473
|
-
// autoseed()
|
|
2474
|
-
// Returns an object for autoseeding, using window.crypto and Node crypto
|
|
2475
|
-
// module if available.
|
|
2476
|
-
//
|
|
2477
|
-
function autoseed() {
|
|
2478
|
-
try {
|
|
2479
|
-
var out;
|
|
2480
|
-
if (nodecrypto && (out = nodecrypto.randomBytes)) {
|
|
2481
|
-
// The use of 'out' to remember randomBytes makes tight minified code.
|
|
2482
|
-
out = out(width);
|
|
2483
|
-
} else {
|
|
2484
|
-
out = new Uint8Array(width);
|
|
2485
|
-
(global.crypto || global.msCrypto).getRandomValues(out);
|
|
2486
|
-
}
|
|
2487
|
-
return tostring(out);
|
|
2488
|
-
} catch (e) {
|
|
2489
|
-
var browser = global.navigator,
|
|
2490
|
-
plugins = browser && browser.plugins;
|
|
2491
|
-
return [+new Date, global, plugins, global.screen, tostring(pool)];
|
|
2492
|
-
}
|
|
2493
|
-
}
|
|
2494
|
-
|
|
2495
|
-
//
|
|
2496
|
-
// tostring()
|
|
2497
|
-
// Converts an array of charcodes to a string
|
|
2498
|
-
//
|
|
2499
|
-
function tostring(a) {
|
|
2500
|
-
return String.fromCharCode.apply(0, a);
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
//
|
|
2504
|
-
// When seedrandom.js is loaded, we immediately mix a few bits
|
|
2505
|
-
// from the built-in RNG into the entropy pool. Because we do
|
|
2506
|
-
// not want to interfere with deterministic PRNG state later,
|
|
2507
|
-
// seedrandom will not call math.random on its own again after
|
|
2508
|
-
// initialization.
|
|
2509
|
-
//
|
|
2510
|
-
mixkey(math.random(), pool);
|
|
2511
|
-
|
|
2512
|
-
//
|
|
2513
|
-
// Nodejs and AMD support: export the implementation as a module using
|
|
2514
|
-
// either convention.
|
|
2515
|
-
//
|
|
2516
|
-
if (module.exports) {
|
|
2517
|
-
module.exports = seedrandom;
|
|
2518
|
-
// When in node.js, try using crypto package for autoseeding.
|
|
2519
|
-
try {
|
|
2520
|
-
nodecrypto = require$$0__default["default"];
|
|
2521
|
-
} catch (ex) {}
|
|
2522
|
-
} else {
|
|
2523
|
-
// When included as a plain script, set up Math.seedrandom global.
|
|
2524
|
-
math['seed' + rngname] = seedrandom;
|
|
2525
|
-
}
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
// End anonymous scope, and pass initial values.
|
|
2529
|
-
})(
|
|
2530
|
-
// global: `self` in browsers (including strict mode and web workers),
|
|
2531
|
-
// otherwise `this` in Node and other environments
|
|
2532
|
-
(typeof self !== 'undefined') ? self : commonjsGlobal,
|
|
2533
|
-
[], // pool: entropy pool starts empty
|
|
2534
|
-
Math // math: package containing random, pow, and seedrandom
|
|
2535
|
-
);
|
|
2536
|
-
}(seedrandom$1));
|
|
2537
|
-
|
|
2538
|
-
// A library of seedable RNGs implemented in Javascript.
|
|
2539
|
-
//
|
|
2540
|
-
// Usage:
|
|
2541
|
-
//
|
|
2542
|
-
// var seedrandom = require('seedrandom');
|
|
2543
|
-
// var random = seedrandom(1); // or any seed.
|
|
2544
|
-
// var x = random(); // 0 <= x < 1. Every bit is random.
|
|
2545
|
-
// var x = random.quick(); // 0 <= x < 1. 32 bits of randomness.
|
|
2546
|
-
|
|
2547
|
-
// alea, a 53-bit multiply-with-carry generator by Johannes Baagøe.
|
|
2548
|
-
// Period: ~2^116
|
|
2549
|
-
// Reported to pass all BigCrush tests.
|
|
2550
|
-
var alea = alea$1.exports;
|
|
2551
|
-
|
|
2552
|
-
// xor128, a pure xor-shift generator by George Marsaglia.
|
|
2553
|
-
// Period: 2^128-1.
|
|
2554
|
-
// Reported to fail: MatrixRank and LinearComp.
|
|
2555
|
-
var xor128 = xor128$1.exports;
|
|
1634
|
+
// A port of an algorithm by Johannes Baagøe <baagoe@baagoe.com>, 2010
|
|
1635
|
+
// http://baagoe.com/en/RandomMusings/javascript/
|
|
1636
|
+
// https://github.com/nquinlan/better-random-numbers-for-javascript-mirror
|
|
1637
|
+
// Original work is under MIT license -
|
|
1638
|
+
|
|
1639
|
+
// Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
|
|
1640
|
+
//
|
|
1641
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1642
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
1643
|
+
// in the Software without restriction, including without limitation the rights
|
|
1644
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1645
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
1646
|
+
// furnished to do so, subject to the following conditions:
|
|
1647
|
+
//
|
|
1648
|
+
// The above copyright notice and this permission notice shall be included in
|
|
1649
|
+
// all copies or substantial portions of the Software.
|
|
1650
|
+
//
|
|
1651
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1652
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1653
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1654
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1655
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1656
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1657
|
+
// THE SOFTWARE.
|
|
1658
|
+
|
|
1659
|
+
|
|
1660
|
+
|
|
1661
|
+
(function(global, module, define) {
|
|
1662
|
+
|
|
1663
|
+
function Alea(seed) {
|
|
1664
|
+
var me = this, mash = Mash();
|
|
1665
|
+
|
|
1666
|
+
me.next = function() {
|
|
1667
|
+
var t = 2091639 * me.s0 + me.c * 2.3283064365386963e-10; // 2^-32
|
|
1668
|
+
me.s0 = me.s1;
|
|
1669
|
+
me.s1 = me.s2;
|
|
1670
|
+
return me.s2 = t - (me.c = t | 0);
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
// Apply the seeding algorithm from Baagoe.
|
|
1674
|
+
me.c = 1;
|
|
1675
|
+
me.s0 = mash(' ');
|
|
1676
|
+
me.s1 = mash(' ');
|
|
1677
|
+
me.s2 = mash(' ');
|
|
1678
|
+
me.s0 -= mash(seed);
|
|
1679
|
+
if (me.s0 < 0) { me.s0 += 1; }
|
|
1680
|
+
me.s1 -= mash(seed);
|
|
1681
|
+
if (me.s1 < 0) { me.s1 += 1; }
|
|
1682
|
+
me.s2 -= mash(seed);
|
|
1683
|
+
if (me.s2 < 0) { me.s2 += 1; }
|
|
1684
|
+
mash = null;
|
|
1685
|
+
}
|
|
2556
1686
|
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
1687
|
+
function copy(f, t) {
|
|
1688
|
+
t.c = f.c;
|
|
1689
|
+
t.s0 = f.s0;
|
|
1690
|
+
t.s1 = f.s1;
|
|
1691
|
+
t.s2 = f.s2;
|
|
1692
|
+
return t;
|
|
1693
|
+
}
|
|
2561
1694
|
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
1695
|
+
function impl(seed, opts) {
|
|
1696
|
+
var xg = new Alea(seed),
|
|
1697
|
+
state = opts && opts.state,
|
|
1698
|
+
prng = xg.next;
|
|
1699
|
+
prng.int32 = function() { return (xg.next() * 0x100000000) | 0; };
|
|
1700
|
+
prng.double = function() {
|
|
1701
|
+
return prng() + (prng() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
|
|
1702
|
+
};
|
|
1703
|
+
prng.quick = prng;
|
|
1704
|
+
if (state) {
|
|
1705
|
+
if (typeof(state) == 'object') copy(state, xg);
|
|
1706
|
+
prng.state = function() { return copy(xg, {}); };
|
|
1707
|
+
}
|
|
1708
|
+
return prng;
|
|
1709
|
+
}
|
|
2569
1710
|
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
var
|
|
1711
|
+
function Mash() {
|
|
1712
|
+
var n = 0xefc8249d;
|
|
1713
|
+
|
|
1714
|
+
var mash = function(data) {
|
|
1715
|
+
data = String(data);
|
|
1716
|
+
for (var i = 0; i < data.length; i++) {
|
|
1717
|
+
n += data.charCodeAt(i);
|
|
1718
|
+
var h = 0.02519603282416938 * n;
|
|
1719
|
+
n = h >>> 0;
|
|
1720
|
+
h -= n;
|
|
1721
|
+
h *= n;
|
|
1722
|
+
n = h >>> 0;
|
|
1723
|
+
h -= n;
|
|
1724
|
+
n += h * 0x100000000; // 2^32
|
|
1725
|
+
}
|
|
1726
|
+
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1729
|
+
return mash;
|
|
1730
|
+
}
|
|
2578
1731
|
|
|
2579
|
-
// Tyche-i, by Samuel Neves and Filipe Araujo, is a bit-shifting random
|
|
2580
|
-
// number generator derived from ChaCha, a modern stream cipher.
|
|
2581
|
-
// https://eden.dei.uc.pt/~sneves/pubs/2011-snfa2.pdf
|
|
2582
|
-
// Period: ~2^127
|
|
2583
|
-
// No systematic BigCrush failures reported.
|
|
2584
|
-
var tychei = tychei$1.exports;
|
|
2585
1732
|
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
1733
|
+
if (module && module.exports) {
|
|
1734
|
+
module.exports = impl;
|
|
1735
|
+
} else if (define && define.amd) {
|
|
1736
|
+
define(function() { return impl; });
|
|
1737
|
+
} else {
|
|
1738
|
+
this.alea = impl;
|
|
1739
|
+
}
|
|
2589
1740
|
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
1741
|
+
})(
|
|
1742
|
+
commonjsGlobal,
|
|
1743
|
+
module, // present in node.js
|
|
1744
|
+
(typeof undefined) == 'function' // present with an AMD loader
|
|
1745
|
+
);
|
|
1746
|
+
} (alea));
|
|
2596
1747
|
|
|
2597
|
-
var seedrandom =
|
|
1748
|
+
var seedrandom = alea.exports;
|
|
2598
1749
|
|
|
2599
1750
|
/**
|
|
2600
1751
|
* Uses the `seedrandom` package to replace Math.random() with a seedable PRNG.
|
|
@@ -2602,12 +1753,8 @@ var seedrandom = sr;
|
|
|
2602
1753
|
* @param seed An optional seed. If none is given, a random seed will be generated.
|
|
2603
1754
|
* @returns The seed value.
|
|
2604
1755
|
*/
|
|
2605
|
-
function setSeed(seed) {
|
|
2606
|
-
|
|
2607
|
-
const prng = seedrandom();
|
|
2608
|
-
seed = prng.int32().toString();
|
|
2609
|
-
}
|
|
2610
|
-
seedrandom(seed, { global: true });
|
|
1756
|
+
function setSeed(seed = Math.random().toString()) {
|
|
1757
|
+
Math.random = seedrandom(seed);
|
|
2611
1758
|
return seed;
|
|
2612
1759
|
}
|
|
2613
1760
|
function repeat(array, repetitions, unpack = false) {
|
|
@@ -3568,7 +2715,7 @@ class JsPsych {
|
|
|
3568
2715
|
// write the data from the trial
|
|
3569
2716
|
this.data.write(data);
|
|
3570
2717
|
// get back the data with all of the defaults in
|
|
3571
|
-
const trial_data = this.data.
|
|
2718
|
+
const trial_data = this.data.getLastTrialData();
|
|
3572
2719
|
// for trial-level callbacks, we just want to pass in a reference to the values
|
|
3573
2720
|
// of the DataCollection, for easy access and editing.
|
|
3574
2721
|
const trial_data_values = trial_data.values()[0];
|
|
@@ -4107,6 +3254,7 @@ class JsPsych {
|
|
|
4107
3254
|
}
|
|
4108
3255
|
}
|
|
4109
3256
|
|
|
3257
|
+
// __rollup-babel-import-regenerator-runtime__
|
|
4110
3258
|
// temporary patch for Safari
|
|
4111
3259
|
if (typeof window !== "undefined" &&
|
|
4112
3260
|
window.hasOwnProperty("webkitAudioContext") &&
|