Skip to content

Commit

Permalink
freeze loaded data
Browse files Browse the repository at this point in the history
  • Loading branch information
okaycj committed Apr 18, 2024
1 parent c4f2cf8 commit cf81bd4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"dev": "rollup --config rollup.config.dev.mjs --watch",
"test": "jest --coverage"
},
"dependencies": {
"deep-freeze-es6": "^3.0.2"
},
"devDependencies": {
"@jspsych/config": "^2.0.0",
"jest-fetch-mock": "^3.0.3"
Expand Down
5 changes: 4 additions & 1 deletion packages/data/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import deepFreeze from "deep-freeze-es6";
import {
finish,
retrieveChild,
Expand All @@ -20,7 +21,7 @@ declare global {
}

async function load(response_uuid: string) {
!window.chs &&
if (!window.chs) {
Object.assign(window, {
chs: {
study: await retrieveStudy(),
Expand All @@ -29,6 +30,8 @@ async function load(response_uuid: string) {
response: await retrieveResponse(response_uuid),
},
});
deepFreeze(window.chs);
}
}

export default { load, retrieveResponse, updateResponse, finish };

0 comments on commit cf81bd4

Please sign in to comment.