MCPcopy Create free account
hub / github.com/codemix/graph / serializeValue

Method serializeValue

packages/graph/src/Steps.ts:4166–4189  ·  view source on GitHub ↗

* Serialize a value for comparison/deduplication.

(value: unknown)

Source from the content-addressed store, hash-verified

4164 * Serialize a value for comparison/deduplication.
4165 */
4166 protected serializeValue(value: unknown): unknown {
4167 if (value instanceof Vertex) {
4168 return { type: "vertex", id: value.id };
4169 }
4170 if (value instanceof Edge) {
4171 return { type: "edge", id: value.id };
4172 }
4173 if (value instanceof TraversalPath) {
4174 // For TraversalPath, serialize the current value
4175 // The path itself carries the full binding context, but for deduplication
4176 // we care about the actual result value
4177 return {
4178 type: "path",
4179 value: this.serializeValue(value.value),
4180 };
4181 }
4182 if (Array.isArray(value)) {
4183 return value.map((v) => this.serializeValue(v));
4184 }
4185 if (value && typeof value === "object") {
4186 return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, this.serializeValue(v)]));
4187 }
4188 return value;
4189 }
4190
4191 public override toStringTokens(): StepStringToken[] {
4192 const tokens: StepStringToken[] = [

Callers 1

getDeduplicationKeyMethod · 0.95

Calls 1

mapMethod · 0.45

Tested by

no test coverage detected