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.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
7
7
|
|
|
8
8
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -27,6 +27,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
31
|
+
|
|
30
32
|
// Gets all non-builtin properties up the prototype chain
|
|
31
33
|
const getAllProperties = object => {
|
|
32
34
|
const properties = new Set();
|
|
@@ -69,7 +71,7 @@ var autoBind = (self, {include, exclude} = {}) => {
|
|
|
69
71
|
return self;
|
|
70
72
|
};
|
|
71
73
|
|
|
72
|
-
var version = "7.
|
|
74
|
+
var version = "7.2.2";
|
|
73
75
|
|
|
74
76
|
class MigrationError extends Error {
|
|
75
77
|
constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
|
|
@@ -409,6 +411,9 @@ class DataCollection {
|
|
|
409
411
|
filterCustom(fn) {
|
|
410
412
|
return new DataCollection(this.trials.filter(fn));
|
|
411
413
|
}
|
|
414
|
+
filterColumns(columns) {
|
|
415
|
+
return new DataCollection(this.trials.map((trial) => Object.fromEntries(columns.filter((key) => key in trial).map((key) => [key, trial[key]]))));
|
|
416
|
+
}
|
|
412
417
|
select(column) {
|
|
413
418
|
const values = [];
|
|
414
419
|
for (const trial of this.trials) {
|
|
@@ -1623,6 +1628,135 @@ var randomWords$1 = words;
|
|
|
1623
1628
|
// Export the word list as it is often useful
|
|
1624
1629
|
words.wordList = wordList;
|
|
1625
1630
|
|
|
1631
|
+
var alea = {exports: {}};
|
|
1632
|
+
|
|
1633
|
+
(function (module) {
|
|
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
|
+
}
|
|
1686
|
+
|
|
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
|
+
}
|
|
1694
|
+
|
|
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
|
+
}
|
|
1710
|
+
|
|
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
|
+
}
|
|
1731
|
+
|
|
1732
|
+
|
|
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
|
+
}
|
|
1740
|
+
|
|
1741
|
+
})(
|
|
1742
|
+
commonjsGlobal,
|
|
1743
|
+
module, // present in node.js
|
|
1744
|
+
(typeof undefined) == 'function' // present with an AMD loader
|
|
1745
|
+
);
|
|
1746
|
+
} (alea));
|
|
1747
|
+
|
|
1748
|
+
var seedrandom = alea.exports;
|
|
1749
|
+
|
|
1750
|
+
/**
|
|
1751
|
+
* Uses the `seedrandom` package to replace Math.random() with a seedable PRNG.
|
|
1752
|
+
*
|
|
1753
|
+
* @param seed An optional seed. If none is given, a random seed will be generated.
|
|
1754
|
+
* @returns The seed value.
|
|
1755
|
+
*/
|
|
1756
|
+
function setSeed(seed = Math.random().toString()) {
|
|
1757
|
+
Math.random = seedrandom(seed);
|
|
1758
|
+
return seed;
|
|
1759
|
+
}
|
|
1626
1760
|
function repeat(array, repetitions, unpack = false) {
|
|
1627
1761
|
const arr_isArray = Array.isArray(array);
|
|
1628
1762
|
const rep_isArray = Array.isArray(repetitions);
|
|
@@ -1905,6 +2039,7 @@ function unpackArray(array) {
|
|
|
1905
2039
|
|
|
1906
2040
|
var randomization = /*#__PURE__*/Object.freeze({
|
|
1907
2041
|
__proto__: null,
|
|
2042
|
+
setSeed: setSeed,
|
|
1908
2043
|
repeat: repeat,
|
|
1909
2044
|
shuffle: shuffle,
|
|
1910
2045
|
shuffleNoRepeats: shuffleNoRepeats,
|
|
@@ -2580,7 +2715,7 @@ class JsPsych {
|
|
|
2580
2715
|
// write the data from the trial
|
|
2581
2716
|
this.data.write(data);
|
|
2582
2717
|
// get back the data with all of the defaults in
|
|
2583
|
-
const trial_data = this.data.
|
|
2718
|
+
const trial_data = this.data.getLastTrialData();
|
|
2584
2719
|
// for trial-level callbacks, we just want to pass in a reference to the values
|
|
2585
2720
|
// of the DataCollection, for easy access and editing.
|
|
2586
2721
|
const trial_data_values = trial_data.values()[0];
|
|
@@ -2629,7 +2764,10 @@ class JsPsych {
|
|
|
2629
2764
|
// done with callbacks
|
|
2630
2765
|
this.internal.call_immediate = false;
|
|
2631
2766
|
// wait for iti
|
|
2632
|
-
if (
|
|
2767
|
+
if (this.simulation_mode === "data-only") {
|
|
2768
|
+
this.nextTrial();
|
|
2769
|
+
}
|
|
2770
|
+
else if (typeof current_trial.post_trial_gap === null ||
|
|
2633
2771
|
typeof current_trial.post_trial_gap === "undefined") {
|
|
2634
2772
|
if (this.opts.default_iti > 0) {
|
|
2635
2773
|
setTimeout(this.nextTrial, this.opts.default_iti);
|