MCPcopy
hub / github.com/flightcontrolhq/superjson / serialize

Method serialize

src/index.ts:33–61  ·  view source on GitHub ↗
(object: SuperJSONValue)

Source from the content-addressed store, hash-verified

31 }
32
33 serialize(object: SuperJSONValue): SuperJSONResult {
34 const identities = new Map<any, any[][]>();
35 const output = walker(object, identities, this, this.dedupe);
36 const res: SuperJSONResult = {
37 json: output.transformedValue,
38 };
39
40 if (output.annotations) {
41 res.meta = {
42 ...res.meta,
43 values: output.annotations,
44 };
45 }
46
47 const equalityAnnotations = generateReferentialEqualityAnnotations(
48 identities,
49 this.dedupe
50 );
51 if (equalityAnnotations) {
52 res.meta = {
53 ...res.meta,
54 referentialEqualities: equalityAnnotations,
55 };
56 }
57
58 if (res.meta) res.meta.v = 1;
59
60 return res;
61 }
62
63 deserialize<T = unknown>(payload: SuperJSONResult, options?: { inPlace?: boolean }): T {
64 const { json, meta } = payload;

Callers 5

stringifyMethod · 0.95
benchmark.jsFile · 0.80
index.test.tsFile · 0.80
transformer.tsFile · 0.80

Calls 2

walkerFunction · 0.85

Tested by

no test coverage detected