MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / resultToJSON

Method resultToJSON

src/common/result.ts:89–100  ·  view source on GitHub ↗
(result: Result<T>)

Source from the content-addressed store, hash-verified

87 }
88
89 static resultToJSON<T>(result: Result<T>): string {
90 if (result.ok) {
91 return JSON.stringify({
92 ok: true,
93 value: result.value,
94 });
95 }
96 return JSON.stringify({
97 ok: false,
98 error: result.error?.toString(),
99 });
100 }
101
102 static resultFromJSON<T>(json: string): Result<T> {
103 const obj = JSON.parse(json);

Callers 1

toJSONMethod · 0.80

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected