MCPcopy Create free account
hub / github.com/OpenAnonymity/oa-chat / remove

Method remove

vector/memoryBackend.js:149–172  ·  view source on GitHub ↗
(ids)

Source from the content-addressed store, hash-verified

147 }
148
149 async remove(ids) {
150 const targetIds = Array.isArray(ids) ? ids : [ids];
151 let removed = 0;
152 for (const idValue of targetIds) {
153 const id = toId(idValue);
154 const index = this.idToIndex.get(id);
155 if (index === undefined) continue;
156
157 const lastIndex = this.size - 1;
158 if (index !== lastIndex) {
159 this._moveVector(lastIndex, index);
160 this.ids[index] = this.ids[lastIndex];
161 this.metadata[index] = this.metadata[lastIndex];
162 this.idToIndex.set(this.ids[index], index);
163 }
164
165 this.ids[lastIndex] = undefined;
166 this.metadata[lastIndex] = undefined;
167 this.idToIndex.delete(id);
168 this.size -= 1;
169 removed += 1;
170 }
171 return removed;
172 }
173
174 async get(ids, options = {}) {
175 const targetIds = Array.isArray(ids) ? ids : [ids];

Callers

nothing calls this directly

Calls 4

_moveVectorMethod · 0.95
toIdFunction · 0.90
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected