MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / toStorageValueStr

Function toStorageValueStr

src/pkg/utils/utils.ts:59–74  ·  view source on GitHub ↗
(val: unknown)

Source from the content-addressed store, hash-verified

57}
58
59export function toStorageValueStr(val: unknown): string {
60 switch (typeof val) {
61 case "string":
62 return `s${val}`;
63 case "number":
64 return `n${val}`;
65 case "boolean":
66 return `b${val}`;
67 default:
68 try {
69 return `o${JSON.stringify(val)}`;
70 } catch {
71 return "";
72 }
73 }
74}
75
76export function parseStorageValue(str: string): unknown {
77 if (str === "") {

Callers 1

writeScriptMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected