Created
December 29, 2019 13:26
-
-
Save WimJongeneel/db7b79719b5f6af73cdd742799af0f8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExprBuilder { | |
constructor(protected ast: Expr) { } | |
GetExpr = () => this.ast | |
equals(v: string | number | boolean | ExprBuilder) { | |
if (['string', 'number', 'boolean'].indexOf(typeof v) != -1) { | |
return new ExprBuilder(createBinaryExpression('==', this.ast, createValExpression(v))) | |
} | |
return new ExprBuilder(createBinaryExpression('==', this.ast, (v as ExprBuilder).GetExpr())) | |
} | |
and(e: ExprBuilder) { | |
return new ExprBuilder((createBinaryExpression('&&', this.ast, e.GetExpr()))) | |
} | |
includes(e: ExprBuilder| string) { | |
if (typeof e == 'string') | |
return new ExprBuilder(createBinaryExpression('includes', this.ast, createValExpression(e))) | |
return new ExprBuilder(createBinaryExpression('includes', this.ast, e.GetExpr())) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment