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

Method getBiDirectionalMaps

external/.scrollLibs.js:15535–15554  ·  view source on GitHub ↗
(propertyNameOrFn, propertyNameOrFn2 = particle => particle.getAtom(0))

Source from the content-addressed store, hash-verified

15533 }
15534 // todo: rename. what is the proper term from set/cat theory?
15535 getBiDirectionalMaps(propertyNameOrFn, propertyNameOrFn2 = particle => particle.getAtom(0)) {
15536 const oneToTwo = {}
15537 const twoToOne = {}
15538 const is1Str = typeof propertyNameOrFn === "string"
15539 const is2Str = typeof propertyNameOrFn2 === "string"
15540 const subparticles = this.getSubparticles()
15541 this.forEach((particle, index) => {
15542 const value1 = is1Str ? particle.get(propertyNameOrFn) : propertyNameOrFn(particle, index, subparticles)
15543 const value2 = is2Str ? particle.get(propertyNameOrFn2) : propertyNameOrFn2(particle, index, subparticles)
15544 if (value1 !== undefined) {
15545 if (!oneToTwo[value1]) oneToTwo[value1] = []
15546 oneToTwo[value1].push(value2)
15547 }
15548 if (value2 !== undefined) {
15549 if (!twoToOne[value2]) twoToOne[value2] = []
15550 twoToOne[value2].push(value1)
15551 }
15552 })
15553 return [oneToTwo, twoToOne]
15554 }
15555 _getAtomIndexCharacterStartPosition(atomIndex) {
15556 const xiLength = this.edgeSymbol.length
15557 const numIndents = this._getIndentLevel() - 1

Callers

nothing calls this directly

Calls 4

getSubparticlesMethod · 0.95
forEachMethod · 0.95
getAtomMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected