Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function reduceTreeBySelector(selector, root) {
if (typeof selector !== 'string') {
const elements = elementsByConstructor(selector);
if (elements.length > 0) {
return flat(elements.map((x) => reduceTreeBySelector(x.tag, root)));
// when https://github.com/aweary/rst-selector-parser/issues/15 is resolved
// const htmlTagNames = elements.map(x => x.tag).join(', ');
// return reduceTreeBySelector(htmlTagNames, root);
}
}
if (typeof selector === 'function' || typeof selector === 'object') {
return treeFilter(root, buildPredicate(selector));
}
let results = [];
if (typeof selector === 'string') {
const tokens = safelyGenerateTokens(selector);