jspsych 8.0.2 → 8.1.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/dist/index.browser.js +9 -10
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +3 -3
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +8 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -7
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/modules/randomization.ts +29 -10
- package/src/timeline/Timeline.spec.ts +105 -5
- package/src/timeline/Timeline.ts +12 -9
package/dist/index.d.ts
CHANGED
|
@@ -204,7 +204,7 @@ declare class Timeline extends TimelineNode {
|
|
|
204
204
|
* If the timeline is running or paused, aborts the timeline after the current trial has completed
|
|
205
205
|
*/
|
|
206
206
|
abort(): void;
|
|
207
|
-
private
|
|
207
|
+
private instantiateChildNode;
|
|
208
208
|
private currentTimelineVariables;
|
|
209
209
|
private setCurrentTimelineVariablesByIndex;
|
|
210
210
|
/**
|
|
@@ -742,11 +742,11 @@ type PluginAPI = ReturnType<typeof createJointPluginAPIObject>;
|
|
|
742
742
|
*/
|
|
743
743
|
declare function setSeed(seed?: string): string;
|
|
744
744
|
declare function repeat(array: any, repetitions: any, unpack?: boolean): any;
|
|
745
|
-
declare function shuffle(array: Array<
|
|
746
|
-
declare function shuffleNoRepeats(arr: Array<
|
|
747
|
-
declare function shuffleAlternateGroups(arr_groups:
|
|
748
|
-
declare function sampleWithoutReplacement(arr:
|
|
749
|
-
declare function sampleWithReplacement(arr:
|
|
745
|
+
declare function shuffle<T>(array: Array<T>): T[];
|
|
746
|
+
declare function shuffleNoRepeats<T>(arr: Array<T>, equalityTest: (a: T, b: T) => boolean): T[];
|
|
747
|
+
declare function shuffleAlternateGroups<T extends any[]>(arr_groups: Array<T>, random_group_order?: boolean): any[];
|
|
748
|
+
declare function sampleWithoutReplacement<T>(arr: Array<T>, size: number): T[];
|
|
749
|
+
declare function sampleWithReplacement<T>(arr: Array<T>, size: number, weights?: number[]): any[];
|
|
750
750
|
declare function factorial(factors: Record<string, any>, repetitions?: number, unpack?: boolean): any;
|
|
751
751
|
declare function randomID(length?: number): string;
|
|
752
752
|
/**
|
|
@@ -765,6 +765,19 @@ declare function sampleBernoulli(p: number): 0 | 1;
|
|
|
765
765
|
declare function sampleNormal(mean: number, standard_deviation: number): number;
|
|
766
766
|
declare function sampleExponential(rate: number): number;
|
|
767
767
|
declare function sampleExGaussian(mean: number, standard_deviation: number, rate: number, positive?: boolean): number;
|
|
768
|
+
type RandomWordsOptions = {
|
|
769
|
+
min?: number;
|
|
770
|
+
max?: number;
|
|
771
|
+
exactly?: number;
|
|
772
|
+
maxLength?: number;
|
|
773
|
+
wordsPerString?: number;
|
|
774
|
+
seperator?: string;
|
|
775
|
+
formatter?: (word: string, index: number) => string;
|
|
776
|
+
join?: string;
|
|
777
|
+
};
|
|
778
|
+
type RandomWordsResult<T extends RandomWordsOptions> = T extends {
|
|
779
|
+
join: string;
|
|
780
|
+
} ? string : string[];
|
|
768
781
|
/**
|
|
769
782
|
* Generate one or more random words.
|
|
770
783
|
*
|
|
@@ -775,7 +788,7 @@ declare function sampleExGaussian(mean: number, standard_deviation: number, rate
|
|
|
775
788
|
*
|
|
776
789
|
* @returns An array of words or a single string, depending on parameter choices.
|
|
777
790
|
*/
|
|
778
|
-
declare function randomWords(opts:
|
|
791
|
+
declare function randomWords<T extends RandomWordsOptions>(opts: T): RandomWordsResult<T>;
|
|
779
792
|
|
|
780
793
|
declare const randomization_setSeed: typeof setSeed;
|
|
781
794
|
declare const randomization_repeat: typeof repeat;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import seedrandom from 'seedrandom/lib/alea';
|
|
|
4
4
|
|
|
5
5
|
var _package = {
|
|
6
6
|
name: "jspsych",
|
|
7
|
-
version: "8.0
|
|
7
|
+
version: "8.1.0",
|
|
8
8
|
description: "Behavioral experiments in a browser",
|
|
9
9
|
type: "module",
|
|
10
10
|
main: "dist/index.cjs",
|
|
@@ -52,7 +52,7 @@ var _package = {
|
|
|
52
52
|
},
|
|
53
53
|
devDependencies: {
|
|
54
54
|
"@fontsource/open-sans": "4.5.3",
|
|
55
|
-
"@jspsych/config": "^3.0.
|
|
55
|
+
"@jspsych/config": "^3.0.1",
|
|
56
56
|
"@types/dom-mediacapture-record": "^1.0.11",
|
|
57
57
|
"base64-inline-loader": "^2.0.1",
|
|
58
58
|
"css-loader": "^6.6.0",
|
|
@@ -2038,7 +2038,8 @@ class Timeline extends TimelineNode {
|
|
|
2038
2038
|
}
|
|
2039
2039
|
for (const timelineVariableIndex of timelineVariableOrder) {
|
|
2040
2040
|
this.setCurrentTimelineVariablesByIndex(timelineVariableIndex);
|
|
2041
|
-
for (const
|
|
2041
|
+
for (const childNodeDescription of this.description.timeline) {
|
|
2042
|
+
const childNode = this.instantiateChildNode(childNodeDescription);
|
|
2042
2043
|
const previousChild = this.currentChild;
|
|
2043
2044
|
this.currentChild = childNode;
|
|
2044
2045
|
childNode.index = previousChild ? previousChild.getLatestNode().index + 1 : this.index;
|
|
@@ -2095,12 +2096,10 @@ class Timeline extends TimelineNode {
|
|
|
2095
2096
|
}
|
|
2096
2097
|
}
|
|
2097
2098
|
}
|
|
2098
|
-
|
|
2099
|
-
const
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
this.children.push(...newChildNodes);
|
|
2103
|
-
return newChildNodes;
|
|
2099
|
+
instantiateChildNode(childDescription) {
|
|
2100
|
+
const newChildNode = isTimelineDescription(childDescription) ? new Timeline(this.dependencies, childDescription, this) : new Trial(this.dependencies, childDescription, this);
|
|
2101
|
+
this.children.push(newChildNode);
|
|
2102
|
+
return newChildNode;
|
|
2104
2103
|
}
|
|
2105
2104
|
setCurrentTimelineVariablesByIndex(index) {
|
|
2106
2105
|
this.currentTimelineVariables = {
|