(names: string[] | undefined, ctx: PredicateContext)
| 67 | * @throws Error if an unknown predicate name is referenced |
| 68 | */ |
| 69 | export function evalPredicates(names: string[] | undefined, ctx: PredicateContext): boolean { |
| 70 | if (!names || names.length === 0) { |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | for (const name of names) { |
| 75 | const fn = PREDICATES[name]; |
| 76 | if (!fn) { |
| 77 | throw new Error( |
| 78 | `Unknown predicate '${name}'. Available predicates: ${Object.keys(PREDICATES).join(', ')}`, |
| 79 | ); |
| 80 | } |
| 81 | if (!fn(ctx)) { |
| 82 | return false; |
| 83 | } |
| 84 | } |
| 85 | return true; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Get all available predicate names. |
no outgoing calls
no test coverage detected