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