jspsych 7.1.2 → 7.2.2
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/index.browser.js +142 -4
- 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 +142 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +142 -4
- package/dist/index.js.map +1 -1
- package/dist/modules/data/DataCollection.d.ts +1 -0
- package/dist/modules/randomization.d.ts +7 -0
- package/package.json +20 -7
- package/src/JsPsych.ts +4 -2
- package/src/index.scss +209 -0
- package/src/modules/data/DataCollection.ts +8 -0
- package/src/modules/randomization.ts +12 -0
package/dist/index.browser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var jsPsychModule = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/******************************************************************************
|
|
5
5
|
Copyright (c) Microsoft Corporation.
|
|
6
6
|
|
|
7
7
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -26,6 +26,8 @@ var jsPsychModule = (function (exports) {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
30
|
+
|
|
29
31
|
// Gets all non-builtin properties up the prototype chain
|
|
30
32
|
const getAllProperties = object => {
|
|
31
33
|
const properties = new Set();
|
|
@@ -68,7 +70,7 @@ var jsPsychModule = (function (exports) {
|
|
|
68
70
|
return self;
|
|
69
71
|
};
|
|
70
72
|
|
|
71
|
-
var version = "7.
|
|
73
|
+
var version = "7.2.2";
|
|
72
74
|
|
|
73
75
|
class MigrationError extends Error {
|
|
74
76
|
constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
|
|
@@ -408,6 +410,9 @@ var jsPsychModule = (function (exports) {
|
|
|
408
410
|
filterCustom(fn) {
|
|
409
411
|
return new DataCollection(this.trials.filter(fn));
|
|
410
412
|
}
|
|
413
|
+
filterColumns(columns) {
|
|
414
|
+
return new DataCollection(this.trials.map((trial) => Object.fromEntries(columns.filter((key) => key in trial).map((key) => [key, trial[key]]))));
|
|
415
|
+
}
|
|
411
416
|
select(column) {
|
|
412
417
|
const values = [];
|
|
413
418
|
for (const trial of this.trials) {
|
|
@@ -1622,6 +1627,135 @@ var jsPsychModule = (function (exports) {
|
|
|
1622
1627
|
// Export the word list as it is often useful
|
|
1623
1628
|
words.wordList = wordList;
|
|
1624
1629
|
|
|
1630
|
+
var alea = {exports: {}};
|
|
1631
|
+
|
|
1632
|
+
(function (module) {
|
|
1633
|
+
// A port of an algorithm by Johannes Baagøe <baagoe@baagoe.com>, 2010
|
|
1634
|
+
// http://baagoe.com/en/RandomMusings/javascript/
|
|
1635
|
+
// https://github.com/nquinlan/better-random-numbers-for-javascript-mirror
|
|
1636
|
+
// Original work is under MIT license -
|
|
1637
|
+
|
|
1638
|
+
// Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
|
|
1639
|
+
//
|
|
1640
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1641
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
1642
|
+
// in the Software without restriction, including without limitation the rights
|
|
1643
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1644
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
1645
|
+
// furnished to do so, subject to the following conditions:
|
|
1646
|
+
//
|
|
1647
|
+
// The above copyright notice and this permission notice shall be included in
|
|
1648
|
+
// all copies or substantial portions of the Software.
|
|
1649
|
+
//
|
|
1650
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1651
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1652
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1653
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1654
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1655
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1656
|
+
// THE SOFTWARE.
|
|
1657
|
+
|
|
1658
|
+
|
|
1659
|
+
|
|
1660
|
+
(function(global, module, define) {
|
|
1661
|
+
|
|
1662
|
+
function Alea(seed) {
|
|
1663
|
+
var me = this, mash = Mash();
|
|
1664
|
+
|
|
1665
|
+
me.next = function() {
|
|
1666
|
+
var t = 2091639 * me.s0 + me.c * 2.3283064365386963e-10; // 2^-32
|
|
1667
|
+
me.s0 = me.s1;
|
|
1668
|
+
me.s1 = me.s2;
|
|
1669
|
+
return me.s2 = t - (me.c = t | 0);
|
|
1670
|
+
};
|
|
1671
|
+
|
|
1672
|
+
// Apply the seeding algorithm from Baagoe.
|
|
1673
|
+
me.c = 1;
|
|
1674
|
+
me.s0 = mash(' ');
|
|
1675
|
+
me.s1 = mash(' ');
|
|
1676
|
+
me.s2 = mash(' ');
|
|
1677
|
+
me.s0 -= mash(seed);
|
|
1678
|
+
if (me.s0 < 0) { me.s0 += 1; }
|
|
1679
|
+
me.s1 -= mash(seed);
|
|
1680
|
+
if (me.s1 < 0) { me.s1 += 1; }
|
|
1681
|
+
me.s2 -= mash(seed);
|
|
1682
|
+
if (me.s2 < 0) { me.s2 += 1; }
|
|
1683
|
+
mash = null;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
function copy(f, t) {
|
|
1687
|
+
t.c = f.c;
|
|
1688
|
+
t.s0 = f.s0;
|
|
1689
|
+
t.s1 = f.s1;
|
|
1690
|
+
t.s2 = f.s2;
|
|
1691
|
+
return t;
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
function impl(seed, opts) {
|
|
1695
|
+
var xg = new Alea(seed),
|
|
1696
|
+
state = opts && opts.state,
|
|
1697
|
+
prng = xg.next;
|
|
1698
|
+
prng.int32 = function() { return (xg.next() * 0x100000000) | 0; };
|
|
1699
|
+
prng.double = function() {
|
|
1700
|
+
return prng() + (prng() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
|
|
1701
|
+
};
|
|
1702
|
+
prng.quick = prng;
|
|
1703
|
+
if (state) {
|
|
1704
|
+
if (typeof(state) == 'object') copy(state, xg);
|
|
1705
|
+
prng.state = function() { return copy(xg, {}); };
|
|
1706
|
+
}
|
|
1707
|
+
return prng;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
function Mash() {
|
|
1711
|
+
var n = 0xefc8249d;
|
|
1712
|
+
|
|
1713
|
+
var mash = function(data) {
|
|
1714
|
+
data = String(data);
|
|
1715
|
+
for (var i = 0; i < data.length; i++) {
|
|
1716
|
+
n += data.charCodeAt(i);
|
|
1717
|
+
var h = 0.02519603282416938 * n;
|
|
1718
|
+
n = h >>> 0;
|
|
1719
|
+
h -= n;
|
|
1720
|
+
h *= n;
|
|
1721
|
+
n = h >>> 0;
|
|
1722
|
+
h -= n;
|
|
1723
|
+
n += h * 0x100000000; // 2^32
|
|
1724
|
+
}
|
|
1725
|
+
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
return mash;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
if (module && module.exports) {
|
|
1733
|
+
module.exports = impl;
|
|
1734
|
+
} else if (define && define.amd) {
|
|
1735
|
+
define(function() { return impl; });
|
|
1736
|
+
} else {
|
|
1737
|
+
this.alea = impl;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
})(
|
|
1741
|
+
commonjsGlobal,
|
|
1742
|
+
module, // present in node.js
|
|
1743
|
+
(typeof undefined) == 'function' // present with an AMD loader
|
|
1744
|
+
);
|
|
1745
|
+
} (alea));
|
|
1746
|
+
|
|
1747
|
+
var seedrandom = alea.exports;
|
|
1748
|
+
|
|
1749
|
+
/**
|
|
1750
|
+
* Uses the `seedrandom` package to replace Math.random() with a seedable PRNG.
|
|
1751
|
+
*
|
|
1752
|
+
* @param seed An optional seed. If none is given, a random seed will be generated.
|
|
1753
|
+
* @returns The seed value.
|
|
1754
|
+
*/
|
|
1755
|
+
function setSeed(seed = Math.random().toString()) {
|
|
1756
|
+
Math.random = seedrandom(seed);
|
|
1757
|
+
return seed;
|
|
1758
|
+
}
|
|
1625
1759
|
function repeat(array, repetitions, unpack = false) {
|
|
1626
1760
|
const arr_isArray = Array.isArray(array);
|
|
1627
1761
|
const rep_isArray = Array.isArray(repetitions);
|
|
@@ -1904,6 +2038,7 @@ var jsPsychModule = (function (exports) {
|
|
|
1904
2038
|
|
|
1905
2039
|
var randomization = /*#__PURE__*/Object.freeze({
|
|
1906
2040
|
__proto__: null,
|
|
2041
|
+
setSeed: setSeed,
|
|
1907
2042
|
repeat: repeat,
|
|
1908
2043
|
shuffle: shuffle,
|
|
1909
2044
|
shuffleNoRepeats: shuffleNoRepeats,
|
|
@@ -2579,7 +2714,7 @@ var jsPsychModule = (function (exports) {
|
|
|
2579
2714
|
// write the data from the trial
|
|
2580
2715
|
this.data.write(data);
|
|
2581
2716
|
// get back the data with all of the defaults in
|
|
2582
|
-
const trial_data = this.data.
|
|
2717
|
+
const trial_data = this.data.getLastTrialData();
|
|
2583
2718
|
// for trial-level callbacks, we just want to pass in a reference to the values
|
|
2584
2719
|
// of the DataCollection, for easy access and editing.
|
|
2585
2720
|
const trial_data_values = trial_data.values()[0];
|
|
@@ -2628,7 +2763,10 @@ var jsPsychModule = (function (exports) {
|
|
|
2628
2763
|
// done with callbacks
|
|
2629
2764
|
this.internal.call_immediate = false;
|
|
2630
2765
|
// wait for iti
|
|
2631
|
-
if (
|
|
2766
|
+
if (this.simulation_mode === "data-only") {
|
|
2767
|
+
this.nextTrial();
|
|
2768
|
+
}
|
|
2769
|
+
else if (typeof current_trial.post_trial_gap === null ||
|
|
2632
2770
|
typeof current_trial.post_trial_gap === "undefined") {
|
|
2633
2771
|
if (this.opts.default_iti > 0) {
|
|
2634
2772
|
setTimeout(this.nextTrial, this.opts.default_iti);
|