MCPcopy Create free account
hub / github.com/cartesiancs/map3d / getCookies

Function getCookies

src/utils/cookie.ts:1–16  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1export const getCookies = () => {
2 try {
3 const cookies = document.cookie.split(";").reduce((res, c) => {
4 const [key, val] = c.trim().split("=").map(decodeURIComponent);
5 try {
6 return Object.assign(res, { [key]: JSON.parse(val) });
7 } catch (e) {
8 return Object.assign(res, { [key]: val });
9 }
10 }, {});
11
12 return cookies;
13 } catch (error) {
14 return "";
15 }
16};
17
18export const getCookie = (key: string) => {
19 const cookieList = getCookies();

Callers 1

getCookieFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected