ts-odata-client
Version:
OData TypeScript Client
25 lines (24 loc) • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypedExpressionVisitor = void 0;
/**
* Evaluates Expression by calling methods on type that follow the pattern of '[operator]Visitor'.
* The operands are passed in as parameters.
*/
var TypedExpressionVisitor = /** @class */ (function () {
function TypedExpressionVisitor() {
}
TypedExpressionVisitor.prototype.visit = function (expression) {
if (!expression)
throw new Error("'expression' is a required parameter.");
if (expression.previous)
this.visit(expression.previous);
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- looking for existence of function in derivied type at runtime
var member = this[expression.operator + "Visitor"];
if (typeof member !== "function")
throw new Error("No method found named '".concat(expression.operator, "Visitor'; '").concat(expression.operator, "' operator is not supported."));
member.apply(this, expression.operands);
};
return TypedExpressionVisitor;
}());
exports.TypedExpressionVisitor = TypedExpressionVisitor;