MCPcopy
hub / github.com/loggerhead/json4u / safeSet

Function safeSet

src/lib/db/config.ts:78–101  ·  view source on GitHub ↗
(key: string, value: any)

Source from the content-addressed store, hash-verified

76}
77
78export async function safeSet(key: string, value: any) {
79 if (typeof window === "undefined") {
80 return;
81 }
82
83 try {
84 if (!globalStore) {
85 init();
86 }
87
88 Cookies.set(key, value, {
89 expires: 365,
90 path: "/editor",
91 sameSite: "strict",
92 });
93 await set(key, value, globalStore);
94 } catch (e) {
95 if ((e as unknown as Error).name === "InvalidStateError") {
96 console.error("InvalidStateError", e);
97 } else {
98 throw e;
99 }
100 }
101}
102
103export async function safeDel(key: string) {
104 if (typeof window === "undefined") {

Callers

nothing calls this directly

Calls 2

setMethod · 0.80
initFunction · 0.70

Tested by

no test coverage detected