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

Method add

packages/graph/src/indexes/BTreeIndex.ts:92–109  ·  view source on GitHub ↗
(elementId: ElementId, value: unknown)

Source from the content-addressed store, hash-verified

90 }
91
92 public add(elementId: ElementId, value: unknown): void {
93 if (value === undefined || value === null) {
94 return;
95 }
96
97 if (typeof value !== "number" && typeof value !== "string") {
98 return;
99 }
100
101 // Store for efficient removal/update
102 this.#elementValues.set(elementId, value);
103
104 // Find insertion point
105 const pos = this.#findInsertionPoint(value);
106
107 // Insert maintaining sort order
108 this.#entries.splice(pos, 0, { value, elementId });
109 }
110
111 public remove(elementId: ElementId, _value: unknown): void {
112 const storedValue = this.#elementValues.get(elementId);

Callers 1

updateMethod · 0.95

Calls 1

#findInsertionPointMethod · 0.95

Tested by

no test coverage detected