MCPcopy Create free account
hub / github.com/esengine/esengine / visit

Function visit

packages/runtime-core/src/utils/DependencyUtils.ts:267–289  ·  view source on GitHub ↗
(item: T)

Source from the content-addressed store, hash-verified

265 const cycleIds: string[] = [];
266
267 const visit = (item: T): boolean => {
268 if (visited.has(item.id)) return true;
269 if (visiting.has(item.id)) {
270 cycleIds.push(item.id);
271 return false; // 发现循环
272 }
273
274 visiting.add(item.id);
275
276 for (const dep of item.dependencies || []) {
277 const depId = resolveId(dep);
278 const depItem = itemMap.get(depId);
279 if (depItem && !visit(depItem)) {
280 cycleIds.push(item.id);
281 return false;
282 }
283 }
284
285 visiting.delete(item.id);
286 visited.add(item.id);
287 sorted.push(item);
288 return true;
289 };
290
291 for (const item of items) {
292 if (!visited.has(item.id)) {

Callers 5

visitMethod · 0.85
visitMethod · 0.85
topologicalSortMethod · 0.85
dfsSortFunction · 0.85

Calls 6

resolveIdFunction · 0.85
hasMethod · 0.65
pushMethod · 0.65
getMethod · 0.65
deleteMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected