MCPcopy Index your code
hub / github.com/TanStack/db / serializeExpression

Function serializeExpression

packages/query-db-collection/src/serialization.ts:60–85  ·  view source on GitHub ↗

* Recursively serializes an IR expression for stable hashing * @internal

(expr: IR.BasicExpression | undefined)

Source from the content-addressed store, hash-verified

58 * @internal
59 */
60function serializeExpression(expr: IR.BasicExpression | undefined): unknown {
61 if (!expr) {
62 return null
63 }
64
65 switch (expr.type) {
66 case `val`:
67 return {
68 type: `val`,
69 value: serializeValue(expr.value),
70 }
71 case `ref`:
72 return {
73 type: `ref`,
74 path: [...expr.path],
75 }
76 case `func`:
77 return {
78 type: `func`,
79 name: expr.name,
80 args: expr.args.map((arg) => serializeExpression(arg)),
81 }
82 default:
83 return null
84 }
85}
86
87/**
88 * Serializes special JavaScript values (undefined, NaN, Infinity, Date)

Callers 1

Calls 2

serializeValueFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected