Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (const [variableKey, variableValue] of Object.entries(parameters)) {
const domain = new RegExp(`(\\(${escapeRegExp(variableKey)}\\))`, "g");
description = description.replace(domain, variableValue);
}
explanationsByScope[result] = explanationsByScope[result] || [];
explanationsByScope[result].push({
scope: result,
description: description,
// TODO: I don't believe these are necessarily correct. However, they
// work with my limited initial test cases, and I've already spent far
// too much time on this.
degreesOfFreedom: [
// The "exact" degree of freedom.
isStrictSuperset(query, result) ? 1 : 0,
// The "parameter" degrees of freedom.
Object.keys(parameters).length,
// The "template" degrees of freedom.
templateSegmentCount
]
});
}
}
// Filter the results to remove redundant explanations that were not
// explicitly requested.
const allExplanationScopes = Object.keys(explanationsByScope);
const filteredResults: Explanation[] = [];
for (const scope of allExplanationScopes) {
(text, i) => !isStrictSuperset(resultScopes, resultScopes[i])
);
allExplanationScopes.some(s => isStrictSuperset(s, scope))
) {