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

Method _cueSort

external/.scrollLibs.js:17375–17390  ·  view source on GitHub ↗
(cueOrder, secondarySortFn)

Source from the content-addressed store, hash-verified

17373 return this.setAtoms(atoms)
17374 }
17375 _cueSort(cueOrder, secondarySortFn) {
17376 const particleAFirst = -1
17377 const particleBFirst = 1
17378 const map = {}
17379 cueOrder.forEach((atom, index) => {
17380 map[atom] = index
17381 })
17382 this.sort((particleA, particleB) => {
17383 const valA = map[particleA.cue]
17384 const valB = map[particleB.cue]
17385 if (valA > valB) return particleBFirst
17386 if (valA < valB) return particleAFirst
17387 return secondarySortFn ? secondarySortFn(particleA, particleB) : 0
17388 })
17389 return this
17390 }
17391 _touchParticle(cuePathArray) {
17392 let contextParticle = this
17393 cuePathArray.forEach(cue => {

Callers 1

cueSortMethod · 0.95

Calls 2

sortMethod · 0.95
forEachMethod · 0.80

Tested by

no test coverage detected