* Transforms a condition expression from PullApprove that is based on python * so that it can be run inside JavaScript. Current transformations: * * 1. `aExpr not in bExpr` --> `!bExpr.includes(aExpr)` * 2. `aExpr in bExpr` --> `bExpr.includes(aExpr`) * 3. `not expr` --> `!e
(expression: string)
| 254 | * 3. `not expr` --> `!expr` |
| 255 | */ |
| 256 | function transformExpressionToJs(expression: string): string { |
| 257 | return expression |
| 258 | .replace(/^(.+)\s+not in\s+(\[.+\])$/, '!$2.includes($1)') |
| 259 | .replace(/^(.+)\s+in\s+(.+)$/, '$2.some(x => $1.matchesAny || $1 == x)') |
| 260 | .replace(/^(.+)\s+not in\s+(.+)$/, '!$2.includes($1)') |
| 261 | .replace(/^(.+)\s+in\s+(.+)$/, '$2.includes($1)') |
| 262 | .replace(/not\s+/g, '!'); |
| 263 | } |
no outgoing calls
no test coverage detected