MCPcopy
hub / github.com/freshframework/fresh / parse

Function parse

packages/fresh/src/jsonify/parse.ts:14–23  ·  view source on GitHub ↗
(
  value: string,
  custom?: CustomParser | undefined,
)

Source from the content-addressed store, hash-verified

12export type CustomParser = Record<string, (value: any) => unknown>;
13
14export function parse<T = unknown>(
15 value: string,
16 custom?: CustomParser | undefined,
17): T {
18 const data = JSON.parse(value);
19 if (!Array.isArray(data)) return unpack([], [], data, custom) as T;
20 const hydrated = new Array(data.length);
21 unpack(data, hydrated, 0, custom);
22 return hydrated[0];
23}
24
25function unpack(
26 arr: unknown[],

Callers 6

round_trip_test.tsFile · 0.90
custom_test.tsFile · 0.90
applyPartialsFunction · 0.90
bootFunction · 0.90
GETFunction · 0.85

Calls 1

unpackFunction · 0.85

Tested by

no test coverage detected