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

Method _getEnumFromAtomTypes

external/.scrollLibs.js:19133–19150  ·  view source on GitHub ↗
(programRootParticle)

Source from the content-addressed store, hash-verified

19131// todo: remove in favor of custom atom type constructors
19132class EnumFromAtomTypesTestParser extends AbstractParsersAtomTestParser {
19133 _getEnumFromAtomTypes(programRootParticle) {
19134 const atomTypeIds = this.getAtomsFrom(1)
19135 const enumGroup = atomTypeIds.join(" ")
19136 // note: hack where we store it on the program. otherwise has global effects.
19137 if (!programRootParticle._enumMaps) programRootParticle._enumMaps = {}
19138 if (programRootParticle._enumMaps[enumGroup]) return programRootParticle._enumMaps[enumGroup]
19139 const atomIndex = 1
19140 const map = {}
19141 const atomTypeMap = {}
19142 atomTypeIds.forEach(typeId => (atomTypeMap[typeId] = true))
19143 programRootParticle.allTypedAtoms
19144 .filter(typedAtom => atomTypeMap[typedAtom.type])
19145 .forEach(typedAtom => {
19146 map[typedAtom.atom] = true
19147 })
19148 programRootParticle._enumMaps[enumGroup] = map
19149 return map
19150 }
19151 // todo: remove
19152 isValid(str, programRootParticle) {
19153 return this._getEnumFromAtomTypes(programRootParticle)[str] === true

Callers 2

isValidMethod · 0.95

Calls 4

getAtomsFromMethod · 0.80
forEachMethod · 0.80
joinMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected