MCPcopy
hub / github.com/graphql/graphql-js / toJSONDeep

Function toJSONDeep

src/__testUtils__/expectJSON.ts:10–24  ·  view source on GitHub ↗

* Deeply transforms an arbitrary value to a JSON-safe value by calling toJSON * on any nested value which defines it.

(value: unknown)

Source from the content-addressed store, hash-verified

8 * on any nested value which defines it.
9 */
10function toJSONDeep(value: unknown): unknown {
11 if (!isObjectLike(value)) {
12 return value;
13 }
14
15 if (typeof value.toJSON === 'function') {
16 return value.toJSON();
17 }
18
19 if (Array.isArray(value)) {
20 return value.map(toJSONDeep);
21 }
22
23 return mapValue(value, toJSONDeep);
24}
25
26export function expectJSON(actual: unknown): {
27 toDeepEqual: (expected: unknown) => ReturnType<typeof expect>;

Callers 4

expectJSONFunction · 0.85
toDeepEqualFunction · 0.85
toDeepNestedPropertyFunction · 0.85
mapExceptionFunction · 0.85

Calls 3

isObjectLikeFunction · 0.90
mapValueFunction · 0.90
toJSONMethod · 0.45

Tested by

no test coverage detected