MCPcopy Create free account
hub / github.com/PatrickSys/codebase-context / sortMemoriesByRecency

Function sortMemoriesByRecency

src/memory/store.ts:156–167  ·  view source on GitHub ↗
(memories: Memory[])

Source from the content-addressed store, hash-verified

154}
155
156export function sortMemoriesByRecency(memories: Memory[]): Memory[] {
157 const withIndex = memories.map((m, i) => ({ m, i }));
158 withIndex.sort((a, b) => {
159 const ad = Date.parse(a.m.date);
160 const bd = Date.parse(b.m.date);
161 const aTime = Number.isFinite(ad) ? ad : 0;
162 const bTime = Number.isFinite(bd) ? bd : 0;
163 if (aTime !== bTime) return bTime - aTime;
164 return a.i - b.i;
165 });
166 return withIndex.map((x) => x.m);
167}
168
169/**
170 * Half-life in days per memory type.

Callers 2

applyUnfilteredLimitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected