|
1 | 1 | "use strict";
|
| 2 | +function __export(m) { |
| 3 | + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; |
| 4 | +} |
2 | 5 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
| -var ExpressionUtils = (function () { |
4 |
| - function ExpressionUtils(_defaultColumnSeparator) { |
5 |
| - if (_defaultColumnSeparator === void 0) { _defaultColumnSeparator = "_"; } |
6 |
| - this._defaultColumnSeparator = _defaultColumnSeparator; |
7 |
| - } |
8 |
| - ExpressionUtils.prototype.getValueByExpression = function (instance, expression) { |
9 |
| - return expression(instance); |
10 |
| - }; |
11 |
| - ExpressionUtils.prototype.getValueByProperties = function (instance, properties) { |
12 |
| - var _this = this; |
13 |
| - var result = instance; |
14 |
| - properties.forEach(function (property) { |
15 |
| - result = _this.getValue(result, property); |
16 |
| - }); |
17 |
| - return result; |
18 |
| - }; |
19 |
| - ExpressionUtils.prototype.getValue = function (instance, property) { |
20 |
| - if (instance) { |
21 |
| - return instance[property]; |
22 |
| - } |
23 |
| - return void 0; |
24 |
| - }; |
25 |
| - ExpressionUtils.prototype.getColumnByExpression = function (expression) { |
26 |
| - return this.getColumnByProperties(this.getPropertiesByExpression(expression)); |
27 |
| - }; |
28 |
| - ExpressionUtils.prototype.getColumnByProperties = function (properties) { |
29 |
| - return properties.join(this._defaultColumnSeparator); |
30 |
| - }; |
31 |
| - ExpressionUtils.prototype.getPropertiesByExpression = function (expression) { |
32 |
| - var strAfterReturn = expression.toString().split("return")[1].trim(); |
33 |
| - if (!strAfterReturn) { |
34 |
| - strAfterReturn = expression.toString().split("{")[1].trim(); |
35 |
| - } |
36 |
| - var strBeforeSemicon = strAfterReturn.split(" ")[0].split(";")[0]; |
37 |
| - return this.getPropertiesByExpressionString(strBeforeSemicon); |
38 |
| - }; |
39 |
| - ExpressionUtils.prototype.getPropertiesByExpressionString = function (expression) { |
40 |
| - var propertiesReferences = expression.split("."); |
41 |
| - if (propertiesReferences.length) |
42 |
| - propertiesReferences.shift(); // remove alias |
43 |
| - return propertiesReferences; |
44 |
| - }; |
45 |
| - ExpressionUtils.prototype.getColumnByLambdaExpression = function (expression) { |
46 |
| - var propertiesMetadada = this.getPropertiesByLambdaExpression(expression); |
47 |
| - return { |
48 |
| - columnLeft: this.getColumnByProperties(propertiesMetadada.propertiesLeft), |
49 |
| - operator: propertiesMetadada.operator, |
50 |
| - columnRight: this.getColumnByProperties(propertiesMetadada.propertiesRight) |
51 |
| - }; |
52 |
| - }; |
53 |
| - ExpressionUtils.prototype.getPropertiesByLambdaExpression = function (expression) { |
54 |
| - var expressionMetadada = this.getExpressionByLambdaExpression(expression); |
55 |
| - return { |
56 |
| - propertiesLeft: this.getPropertiesByExpressionString(expressionMetadada.expressionLeft), |
57 |
| - operator: expressionMetadada.operator, |
58 |
| - propertiesRight: this.getPropertiesByExpressionString(expressionMetadada.expressionRight) |
59 |
| - }; |
60 |
| - }; |
61 |
| - ExpressionUtils.prototype.getExpressionByLambdaExpression = function (expression) { |
62 |
| - var strAfterReturn = expression.toString().split("return")[1].trim(); |
63 |
| - if (!strAfterReturn) { |
64 |
| - strAfterReturn = expression.toString().split("{")[1].trim(); |
65 |
| - } |
66 |
| - var strExpression = strAfterReturn.split(";")[0].split(" "); |
67 |
| - if (strExpression.length != 3) { |
68 |
| - throw "Lambda expression '" + expression.toString() + "' not supported! Use simple expression with '{expressionLeft} {operador} {expressionRight}'"; |
69 |
| - } |
70 |
| - return { |
71 |
| - expressionLeft: strExpression[0], |
72 |
| - operator: strExpression[1], |
73 |
| - expressionRight: strExpression[2] |
74 |
| - }; |
75 |
| - }; |
76 |
| - return ExpressionUtils; |
77 |
| -}()); |
78 |
| -exports.ExpressionUtils = ExpressionUtils; |
| 6 | +__export(require("./expression-utils")); |
0 commit comments