function mergeParserResults()

in src/implementationGuides/index.ts [100:109]


function mergeParserResults(primaryParser: Parser, secondaryParser: Parser) {
    // this takes advantage of the fact that _.uniq traverses the array in order, giving primaryParser an higher priority
    return uniqBy(
        [
            ...primaryParser.results[0], // nearley returns an array of results. The array always has exactly one element for non ambiguous grammars
            ...secondaryParser.results[0],
        ],
        (x) => `${x.resourceType}.${x.path}`,
    );
}