MCPcopy
hub / github.com/github/awesome-copilot / persistState

Function persistState

extensions/site-studio/extension.mjs:562–576  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

560
561let persistQueue = Promise.resolve();
562function persistState() {
563 if (!stateCache) {
564 return persistQueue;
565 }
566 // Snapshot synchronously and serialize writes so concurrent mutations
567 // persist in call order — a slow earlier write can't clobber a newer one.
568 const snapshot = JSON.stringify(stateCache, null, 2);
569 persistQueue = persistQueue
570 .catch(() => {})
571 .then(async () => {
572 await mkdir(ARTIFACTS_DIR, { recursive: true });
573 await writeFile(STATE_FILE, snapshot, "utf8");
574 });
575 return persistQueue;
576}
577
578function normalizeState(raw) {
579 if (!raw || typeof raw !== "object") {

Callers 3

loadStateFunction · 0.85
mutateStateFunction · 0.85
extension.mjsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected