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

Method _createParserInfo

external/.scrollLibs.js:19558–19582  ·  view source on GitHub ↗
(parserIdsInScope)

Source from the content-addressed store, hash-verified

19556 return getters.join("\n")
19557 }
19558 _createParserInfo(parserIdsInScope) {
19559 const result = {
19560 cueMap: {},
19561 regexTests: []
19562 }
19563 if (!parserIdsInScope.length) return result
19564 const allProgramParserDefinitionsMap = this.programParserDefinitionCache
19565 Object.keys(allProgramParserDefinitionsMap)
19566 .filter(parserId => {
19567 const def = allProgramParserDefinitionsMap[parserId]
19568 return def.isOrExtendsAParserInScope(parserIdsInScope) && !def._isAbstract()
19569 })
19570 .forEach(parserId => {
19571 const def = allProgramParserDefinitionsMap[parserId]
19572 const regex = def.regexMatch
19573 const cue = def.cueIfAny
19574 const enumOptions = def.cueEnumOptions
19575 if (regex) result.regexTests.push({ regex: regex, parser: def.parserIdFromDefinition })
19576 else if (cue) result.cueMap[cue] = def
19577 else if (enumOptions) {
19578 enumOptions.forEach(option => (result.cueMap[option] = def))
19579 }
19580 })
19581 return result
19582 }
19583 get topParserDefinitions() {
19584 const arr = Object.values(this.cueMapWithDefinitions)
19585 arr.sort(Utils.makeSortByFn(definition => definition.popularity))

Callers 2

cueMapWithDefinitionsMethod · 0.95
parserAsJavascriptMethod · 0.95

Calls 4

forEachMethod · 0.80
_isAbstractMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected