jspsych 8.0.2 → 8.0.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.d.ts CHANGED
@@ -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<any>): any[];
746
- declare function shuffleNoRepeats(arr: Array<any>, equalityTest: (a: any, b: any) => boolean): any[];
747
- declare function shuffleAlternateGroups(arr_groups: any, random_group_order?: boolean): any[];
748
- declare function sampleWithoutReplacement(arr: any, size: any): any[];
749
- declare function sampleWithReplacement(arr: any, size: any, weights?: any): any[];
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: any): string[];
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.2",
7
+ version: "8.0.3",
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.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",