MCPcopy Index your code
hub / github.com/simstudioai/sim / mergeEntries

Function mergeEntries

apps/sim/stores/terminal/console/storage.ts:113–140  ·  view source on GitHub ↗
(
  existingEntries: ConsoleEntry[] = [],
  incomingEntries: ConsoleEntry[] = []
)

Source from the content-addressed store, hash-verified

111}
112
113function mergeEntries(
114 existingEntries: ConsoleEntry[] = [],
115 incomingEntries: ConsoleEntry[] = []
116): ConsoleEntry[] {
117 const entriesById = new Map<string, ConsoleEntry>()
118 const orderedIds: string[] = []
119
120 for (const entry of existingEntries) {
121 entriesById.set(entry.id, entry)
122 orderedIds.push(entry.id)
123 }
124
125 for (const entry of incomingEntries) {
126 const existing = entriesById.get(entry.id)
127 if (!existing) {
128 entriesById.set(entry.id, entry)
129 orderedIds.push(entry.id)
130 continue
131 }
132 if (shouldReplaceEntry(existing, entry)) {
133 entriesById.set(entry.id, entry)
134 }
135 }
136
137 return orderedIds
138 .map((id) => entriesById.get(id))
139 .filter((entry): entry is ConsoleEntry => !!entry)
140}
141
142function mergePersistedConsoleData(
143 existing: PersistedConsoleData | null,

Callers 1

Calls 4

shouldReplaceEntryFunction · 0.85
setMethod · 0.65
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected