MCPcopy Create free account
hub / github.com/breck7/scroll / _makeGraphSortFunctionFromGraph

Method _makeGraphSortFunctionFromGraph

external/.scrollLibs.js:14521–14539  ·  view source on GitHub ↗
(idAccessor, graph)

Source from the content-addressed store, hash-verified

14519 }
14520 }
14521 static _makeGraphSortFunctionFromGraph(idAccessor, graph) {
14522 return (particleA, particleB) => {
14523 const particleAFirst = -1
14524 const particleBFirst = 1
14525 const particleAUniqueId = idAccessor(particleA)
14526 const particleBUniqueId = idAccessor(particleB)
14527 const particleAExtendsParticleB = graph[particleAUniqueId].has(particleBUniqueId)
14528 const particleBExtendsParticleA = graph[particleBUniqueId].has(particleAUniqueId)
14529 if (particleAExtendsParticleB) return particleBFirst
14530 else if (particleBExtendsParticleA) return particleAFirst
14531 const particleAExtendsSomething = graph[particleAUniqueId].size > 1
14532 const particleBExtendsSomething = graph[particleBUniqueId].size > 1
14533 if (!particleAExtendsSomething && particleBExtendsSomething) return particleAFirst
14534 else if (!particleBExtendsSomething && particleAExtendsSomething) return particleBFirst
14535 if (particleAUniqueId > particleBUniqueId) return particleBFirst
14536 else if (particleAUniqueId < particleBUniqueId) return particleAFirst
14537 return 0
14538 }
14539 }
14540 static removeAll(str, needle) {
14541 return str.split(needle).join("")
14542 }

Callers

nothing calls this directly

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected