-
-
Notifications
You must be signed in to change notification settings - Fork 653
/
migration.ts
37 lines (34 loc) · 1.03 KB
/
migration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export class MigrationError extends Error {
constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
super(
`${message} Please follow the migration guide at https://www.jspsych.org/7.0/support/migration-v7/ to update your experiment.`
);
this.name = "MigrationError";
}
}
// Define a global jsPsych object to handle invocations on it with migration errors
(window as any).jsPsych = {
get init() {
throw new MigrationError("`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.");
},
get data() {
throw new MigrationError();
},
get randomization() {
throw new MigrationError();
},
get turk() {
throw new MigrationError();
},
get pluginAPI() {
throw new MigrationError();
},
get ALL_KEYS() {
throw new MigrationError(
'jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.'
);
},
get NO_KEYS() {
throw new MigrationError('jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.');
},
};