MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / parseStorageValue

Function parseStorageValue

src/pkg/utils/utils.ts:76–98  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

74}
75
76export function parseStorageValue(str: string): unknown {
77 if (str === "") {
78 return undefined;
79 }
80 const t = str[0];
81 const s = str.substring(1);
82 switch (t) {
83 case "b":
84 return s === "true";
85 case "n":
86 return parseFloat(s);
87 case "o":
88 try {
89 return JSON.parse(s);
90 } catch {
91 return str;
92 }
93 case "s":
94 return s;
95 default:
96 return str;
97 }
98}
99
100// https://developer.chrome.com/docs/extensions/reference/api/tabs?hl=en#get_the_current_tab
101export async function getCurrentTab(): Promise<chrome.tabs.Tab | undefined> {

Callers 1

parseMethod · 0.90

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected