feat: recursively generate all possible combinations of selector nodes fromprovided stack

This commit is contained in:
karishmas6
2024-06-05 23:42:27 +05:30
parent 0dd469eae6
commit 134b29ecb9

View File

@@ -411,6 +411,16 @@ export const getSelectors = async (page: Page, coordinates: Coordinates) => {
return value !== null && value !== undefined;
}
function* combinations(stack: Node[][], path: Node[] = []): Generator<Node[]> {
if (stack.length > 0) {
for (let node of stack[0]) {
yield* combinations(stack.slice(1, stack.length), path.concat(node));
}
} else {
yield path;
}
}