function extractFeatures()

in packages/sqrl/src/compile/SqrlTruthTable.ts [104:126]


function extractFeatures(ast: ValidAst): Set<string> {
  if (ast.type === "feature") {
    return new Set([ast.value]);
  } else if (ast.type === "not") {
    return extractFeatures(ast.expr);
  } else if (ast.type === "boolean_expr") {
    sqrlInvariant(
      ast,
      ast.operator === "and" || ast.operator === "or",
      "Only and/or operators are allowed in where clause"
    );
    const features = extractFeatures(ast.left);
    extractFeatures(ast.right).forEach((feature?) => features.add(feature));
    return features;
  } else if (ast.type === "binary_expr") {
    return new Set([binaryFeatureName(ast)]);
  } else {
    throw buildSqrlError(
      ast,
      "Only and/or/not and constant equality allowed in where clause"
    );
  }
}