Skip to content

Commit

Permalink
feat: add getLastTrialData from gearshift into src/lib/utils.js
Browse files Browse the repository at this point in the history
  • Loading branch information
YUUU23 committed Jul 6, 2024
1 parent 890de74 commit 9cb6585
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,13 @@ export function getSeconds(ms) {
export function getTimeString(ms) {
return `${getMinute(ms)}:${getSeconds(ms).toString().padStart(2, "0")}`;
}

/**
* Retrieves the data object from the last trial in JsPsych
* @param {JsPsych} jsPsych jsPsych instance being used to run the task
* @returns {Object}
*/
export function getLastTrialData(jsPsych) {
const dataCollection = jsPsych.data.getLastTrialData();
return dataCollection.trials[0];
}

0 comments on commit 9cb6585

Please sign in to comment.