@jbrowse/jexl 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/dist/Expression.d.ts +16 -6
- package/dist/Expression.js +34 -8
- package/dist/Expression.js.map +1 -1
- package/dist/Jexl.d.ts +13 -12
- package/dist/Jexl.js +31 -30
- package/dist/Jexl.js.map +1 -1
- package/dist/Lexer.d.ts +9 -8
- package/dist/Lexer.js +58 -18
- package/dist/Lexer.js.map +1 -1
- package/dist/evaluator/Evaluator.d.ts +20 -34
- package/dist/evaluator/Evaluator.js +19 -64
- package/dist/evaluator/Evaluator.js.map +1 -1
- package/dist/evaluator/compile.d.ts +27 -0
- package/dist/evaluator/compile.js +261 -0
- package/dist/evaluator/compile.js.map +1 -0
- package/dist/grammar.d.ts +29 -9
- package/dist/grammar.js +19 -3
- package/dist/grammar.js.map +1 -1
- package/dist/parser/Parser.d.ts +5 -7
- package/dist/parser/Parser.js +17 -2
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/handlers.d.ts +0 -6
- package/dist/parser/handlers.js +54 -46
- package/dist/parser/handlers.js.map +1 -1
- package/dist/parser/states.d.ts +2 -2
- package/dist/parser/states.js +0 -20
- package/dist/parser/states.js.map +1 -1
- package/dist/types.d.ts +18 -7
- package/esm/Expression.d.ts +16 -6
- package/esm/Expression.js +34 -8
- package/esm/Expression.js.map +1 -1
- package/esm/Jexl.d.ts +13 -12
- package/esm/Jexl.js +31 -30
- package/esm/Jexl.js.map +1 -1
- package/esm/Lexer.d.ts +9 -8
- package/esm/Lexer.js +58 -18
- package/esm/Lexer.js.map +1 -1
- package/esm/evaluator/Evaluator.d.ts +20 -34
- package/esm/evaluator/Evaluator.js +19 -31
- package/esm/evaluator/Evaluator.js.map +1 -1
- package/esm/evaluator/compile.d.ts +27 -0
- package/esm/evaluator/compile.js +258 -0
- package/esm/evaluator/compile.js.map +1 -0
- package/esm/grammar.d.ts +29 -9
- package/esm/grammar.js +18 -3
- package/esm/grammar.js.map +1 -1
- package/esm/parser/Parser.d.ts +5 -7
- package/esm/parser/Parser.js +17 -2
- package/esm/parser/Parser.js.map +1 -1
- package/esm/parser/handlers.d.ts +0 -6
- package/esm/parser/handlers.js +54 -45
- package/esm/parser/handlers.js.map +1 -1
- package/esm/parser/states.d.ts +2 -2
- package/esm/parser/states.js +0 -20
- package/esm/parser/states.js.map +1 -1
- package/esm/types.d.ts +18 -7
- package/package.json +25 -28
- package/src/Expression.ts +33 -13
- package/src/Jexl.ts +59 -21
- package/src/Lexer.ts +60 -27
- package/src/evaluator/Evaluator.ts +27 -44
- package/src/evaluator/compile.ts +310 -0
- package/src/grammar.ts +66 -17
- package/src/parser/Parser.ts +24 -20
- package/src/parser/handlers.ts +96 -73
- package/src/parser/states.ts +2 -22
- package/src/types.ts +22 -7
- package/CHANGELOG.md +0 -249
- package/dist/evaluator/handlers.d.ts +0 -112
- package/dist/evaluator/handlers.js +0 -208
- package/dist/evaluator/handlers.js.map +0 -1
- package/esm/evaluator/handlers.d.ts +0 -112
- package/esm/evaluator/handlers.js +0 -194
- package/esm/evaluator/handlers.js.map +0 -1
- package/src/evaluator/handlers.ts +0 -212
package/CHANGELOG.md
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
# Jexl Change Log
|
|
2
|
-
|
|
3
|
-
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
|
-
|
|
5
|
-
## [development]
|
|
6
|
-
|
|
7
|
-
Nothing yet!
|
|
8
|
-
|
|
9
|
-
## [v3.0.0]
|
|
10
|
-
|
|
11
|
-
### BREAKING CHANGES
|
|
12
|
-
|
|
13
|
-
- **Removed async evaluation support**: Jexl now only supports synchronous evaluation
|
|
14
|
-
- **Renamed methods**: `evalSync()` has been renamed to `eval()`. The async `eval()` method has been removed.
|
|
15
|
-
- **Removed PromiseSync class**: Internal implementation detail removed
|
|
16
|
-
- **Removed transforms**: The transform/pipe operator (`|`) has been completely removed. Use functions instead.
|
|
17
|
-
- **Removed array filtering**: Relative filter expressions (e.g., `array[.property == value]`) have been removed. Bracket notation for array/object access (e.g., `array[0]`, `object["key"]`) still works.
|
|
18
|
-
- **Removed transform methods**: `addTransform()`, `addTransforms()`, and `getTransform()` have been removed.
|
|
19
|
-
|
|
20
|
-
### Changed
|
|
21
|
-
|
|
22
|
-
- Simplified codebase by removing Promise/PromiseSync abstraction layer
|
|
23
|
-
- All evaluation is now synchronous, improving performance and simplifying error handling
|
|
24
|
-
- Errors are now thrown directly rather than being rejected Promises
|
|
25
|
-
- Removed pipe operator (`|`) from grammar
|
|
26
|
-
- Removed filter bracket syntax for relative filtering
|
|
27
|
-
|
|
28
|
-
### Migration Guide
|
|
29
|
-
|
|
30
|
-
- Replace `await jexl.eval(expr)` with `jexl.eval(expr)` (remove await)
|
|
31
|
-
- Replace `jexl.evalSync(expr)` with `jexl.eval(expr)` (remove Sync suffix)
|
|
32
|
-
- Replace transforms with functions: change `value|transform(arg)` to `transform(value, arg)`
|
|
33
|
-
- Remove uses of relative filtering syntax `array[.prop == value]` (note: direct indexing like `array[0]` still works)
|
|
34
|
-
- Replace `.catch()` error handling with `try/catch` blocks
|
|
35
|
-
|
|
36
|
-
## [v2.3.0]
|
|
37
|
-
|
|
38
|
-
### Added
|
|
39
|
-
|
|
40
|
-
- Top-level expression functions, along with `jexl.addFunction` and
|
|
41
|
-
`jexl.addFunctions`. (#25)
|
|
42
|
-
- Binary operators can now be set to evaluate their operands manually, allowing
|
|
43
|
-
them to decide if and when to resolve the value of the left or right sides.
|
|
44
|
-
See the new `manualEval` option in `jexl.addBinaryOp`.
|
|
45
|
-
- Support for Latin 1 Suppliment characters in identifiers (#68) (@heharkon)
|
|
46
|
-
- Support for Russian chatacters in identifiers (#90) (@a-gorbunov)
|
|
47
|
-
- ES5 build for browser support (#87) (@czosel)
|
|
48
|
-
|
|
49
|
-
### Fixed
|
|
50
|
-
|
|
51
|
-
- The binary operators `&&` and `||` now evaluate the right operand
|
|
52
|
-
conditionally, depending on the value of the left.
|
|
53
|
-
|
|
54
|
-
## [v2.2.2]
|
|
55
|
-
|
|
56
|
-
### Changes
|
|
57
|
-
|
|
58
|
-
- Jexl now officially supports Node v12. It's been working, but now CI tests it!
|
|
59
|
-
|
|
60
|
-
### Fixed
|
|
61
|
-
|
|
62
|
-
- Accessing children of null should resolve to undefined rather than throwing
|
|
63
|
-
(#64)
|
|
64
|
-
|
|
65
|
-
## [v2.2.1]
|
|
66
|
-
|
|
67
|
-
### Fixed
|
|
68
|
-
|
|
69
|
-
- Relative collection filters didn't function appropriately when evalSync was
|
|
70
|
-
used, as it would sometimes revert to using an actual Promise object.
|
|
71
|
-
(#61)
|
|
72
|
-
|
|
73
|
-
## [v2.2.0]
|
|
74
|
-
|
|
75
|
-
### Added
|
|
76
|
-
|
|
77
|
-
- Introducing the `Expression` object, which allows expressions to be compiled
|
|
78
|
-
only once and evaluated many times
|
|
79
|
-
- Get an Expression by calling `jexl.createExpression('2 + 2')`
|
|
80
|
-
- Get a pre-compiled expression by calling `jexl.compile('2 + 2')`
|
|
81
|
-
- Evaluate Expressions asyncronoushly or synchronously by calling
|
|
82
|
-
`myExpression.eval(context)` or `myExpression.evalSync(context)`
|
|
83
|
-
- Create expressions using a convenient tagged template: `` jexl.expr`2 + 2` ``
|
|
84
|
-
|
|
85
|
-
### Fixed
|
|
86
|
-
|
|
87
|
-
- Transform errors did not always get thrown when using `evalSync` (#55, #56)
|
|
88
|
-
(@bitghostm)
|
|
89
|
-
- Arbitrary whitespace is now re-supported (#54) (@czosel)
|
|
90
|
-
- Strings were not tokenized correctly when ending with an escaped quote (#51)
|
|
91
|
-
(@rehandalal)
|
|
92
|
-
- Identifier names can now start with `$` (#36) (@glromeo)
|
|
93
|
-
|
|
94
|
-
## [v2.1.1]
|
|
95
|
-
|
|
96
|
-
### Fixed
|
|
97
|
-
|
|
98
|
-
- Applying a filter to an undefined identifier now returns an empty array
|
|
99
|
-
instead of an array with one undefined element.
|
|
100
|
-
|
|
101
|
-
## [v2.1.0]
|
|
102
|
-
|
|
103
|
-
### Added
|
|
104
|
-
|
|
105
|
-
- Jexl now has synchronous evaluation! Just call `evalSync`.
|
|
106
|
-
|
|
107
|
-
## [v2.0.2]
|
|
108
|
-
|
|
109
|
-
### Fixed
|
|
110
|
-
|
|
111
|
-
- Issue #47: Revert unintentional change to strict === and !== comparisons
|
|
112
|
-
|
|
113
|
-
## [v2.0.1]
|
|
114
|
-
|
|
115
|
-
### Fixed
|
|
116
|
-
|
|
117
|
-
- Issue where Jexl might mistake an identifier as being relative to a parent
|
|
118
|
-
when it should refer to the top level of the context in one specific case
|
|
119
|
-
|
|
120
|
-
## [v2.0.0]
|
|
121
|
-
|
|
122
|
-
### Changed
|
|
123
|
-
|
|
124
|
-
- The pre-minified Jexl has been removed; in modern times, frontend
|
|
125
|
-
webapps have their own build stack, and Jexl should't make assumptions
|
|
126
|
-
about the module format a frontend app wants to use.
|
|
127
|
-
- Support for Node 4 and earlier has been dropped.
|
|
128
|
-
- The codebase has been modernized to the subset of ES6 supported in
|
|
129
|
-
Node 6 LTS and beyond. Tests require Node 8 or later.
|
|
130
|
-
- The codebase has been shifted to Standard JS style.
|
|
131
|
-
- jexl.eval no longer accepts a callback function. Jexl is now promises-only.
|
|
132
|
-
- Tests have been converted to Jest to eliminate sneaky error swallowing
|
|
133
|
-
|
|
134
|
-
## [v1.1.4]
|
|
135
|
-
|
|
136
|
-
### Fixed
|
|
137
|
-
|
|
138
|
-
- Falsey identifiers are no longer treated as undefined
|
|
139
|
-
|
|
140
|
-
## [v1.1.3]
|
|
141
|
-
|
|
142
|
-
### Fixed
|
|
143
|
-
|
|
144
|
-
- Binary operators after nested identifiers were not balanced properly,
|
|
145
|
-
resulting in a broken expression/AST
|
|
146
|
-
- Gulp (or one of its plugins) had a breaking change in a minor release,
|
|
147
|
-
preventing the frontend build from running. This build method will be
|
|
148
|
-
removed from the next major version of Jexl. For now, Jexl is now version-
|
|
149
|
-
locked to the original gulp+plugins that worked.
|
|
150
|
-
|
|
151
|
-
## [v1.1.2]
|
|
152
|
-
|
|
153
|
-
### Changed
|
|
154
|
-
|
|
155
|
-
- Code coverage thresholds are now enforced through `gulp coverage-test`
|
|
156
|
-
|
|
157
|
-
### Fixed
|
|
158
|
-
|
|
159
|
-
- Operators found in identifier names (such as 'in' in 'incident') were being
|
|
160
|
-
tokenized separately from the rest of the identifier
|
|
161
|
-
|
|
162
|
-
## [v1.1.1]
|
|
163
|
-
|
|
164
|
-
### Fixed
|
|
165
|
-
|
|
166
|
-
- Minus did not denote a negative number at the start of a ternary's consequent
|
|
167
|
-
section
|
|
168
|
-
|
|
169
|
-
## [v1.1.0]
|
|
170
|
-
|
|
171
|
-
### Added
|
|
172
|
-
|
|
173
|
-
- The ability to define new binary and unary operators, or override existing
|
|
174
|
-
ones.
|
|
175
|
-
- The ability to delete existing binary and unary operators.
|
|
176
|
-
|
|
177
|
-
## [v1.0.2]
|
|
178
|
-
|
|
179
|
-
### Fixed
|
|
180
|
-
|
|
181
|
-
- Bad Gulpfile resulted in frontend dist falling out of sync. Fixed and
|
|
182
|
-
re-synced.
|
|
183
|
-
|
|
184
|
-
## [v1.0.1]
|
|
185
|
-
|
|
186
|
-
### Changed
|
|
187
|
-
|
|
188
|
-
- Refactored Parser and Evaluator. Both operations are now marginally faster.
|
|
189
|
-
- Removed balance tracking in favor of passing maps of token types at which
|
|
190
|
-
the sub-parser should stop.
|
|
191
|
-
|
|
192
|
-
### Fixed
|
|
193
|
-
|
|
194
|
-
- Object literals could not be defined in the consequent section of a ternary
|
|
195
|
-
expression.
|
|
196
|
-
|
|
197
|
-
## [v1.0.0]
|
|
198
|
-
|
|
199
|
-
### Added
|
|
200
|
-
|
|
201
|
-
- Object literals. Objects can now be defined inline with
|
|
202
|
-
`{standard: 'syntax'}`.
|
|
203
|
-
- Array literals. Arrays can also be defined with `["standard", 'syntax']`.
|
|
204
|
-
- The 'in' operator, for checking to see if a string appears inside a larger
|
|
205
|
-
string, or if an element exists in an array.
|
|
206
|
-
- Ternary expressions with `this ? "standard" : "syntax"`
|
|
207
|
-
- Ternary expressions with `alternate ?: "syntax"`
|
|
208
|
-
|
|
209
|
-
### Changed
|
|
210
|
-
|
|
211
|
-
- Simplified Grammar, reduced RAM footprint
|
|
212
|
-
- Dot notation can now be used to access properties of literals, such as
|
|
213
|
-
`"someString".length` or `{foo: 'bar'}.foo`.
|
|
214
|
-
- Transform syntax has changed. Arguments are now passed in parentheses, and
|
|
215
|
-
multiple arguments can be defined. Arguments are no longer limited to object
|
|
216
|
-
literals.
|
|
217
|
-
|
|
218
|
-
## [v0.2.0]
|
|
219
|
-
|
|
220
|
-
### Added
|
|
221
|
-
|
|
222
|
-
- "Divide and floor" operator: //
|
|
223
|
-
- Documentation outlining running expressions against XML.
|
|
224
|
-
|
|
225
|
-
## v0.1.0
|
|
226
|
-
|
|
227
|
-
### Added
|
|
228
|
-
|
|
229
|
-
- Initial release
|
|
230
|
-
|
|
231
|
-
[development]: https://github.com/TomFrost/Jexl/compare/v2.3.0...HEAD
|
|
232
|
-
[v2.3.0]: https://github.com/TomFrost/Jexl/compare/v2.2.2...v2.3.0
|
|
233
|
-
[v2.2.2]: https://github.com/TomFrost/Jexl/compare/v2.2.1...v2.2.2
|
|
234
|
-
[v2.2.1]: https://github.com/TomFrost/Jexl/compare/v2.2.0...v2.2.1
|
|
235
|
-
[v2.2.0]: https://github.com/TomFrost/Jexl/compare/v2.1.1...v2.2.0
|
|
236
|
-
[v2.1.1]: https://github.com/TomFrost/Jexl/compare/v2.1.0...v2.1.1
|
|
237
|
-
[v2.1.0]: https://github.com/TomFrost/Jexl/compare/v2.0.2...v2.1.0
|
|
238
|
-
[v2.0.2]: https://github.com/TomFrost/Jexl/compare/v2.0.1...v2.0.2
|
|
239
|
-
[v2.0.1]: https://github.com/TomFrost/Jexl/compare/v2.0.0...v2.0.1
|
|
240
|
-
[v2.0.0]: https://github.com/TomFrost/Jexl/compare/1.1.4...v2.0.0
|
|
241
|
-
[v1.1.4]: https://github.com/TomFrost/Jexl/compare/1.1.3...1.1.4
|
|
242
|
-
[v1.1.3]: https://github.com/TomFrost/Jexl/compare/1.1.2...1.1.3
|
|
243
|
-
[v1.1.2]: https://github.com/TomFrost/Jexl/compare/1.1.1...1.1.2
|
|
244
|
-
[v1.1.1]: https://github.com/TomFrost/Jexl/compare/1.1.0...1.1.1
|
|
245
|
-
[v1.1.0]: https://github.com/TomFrost/Jexl/compare/1.0.2...1.1.0
|
|
246
|
-
[v1.0.2]: https://github.com/TomFrost/Jexl/compare/1.0.1...1.0.2
|
|
247
|
-
[v1.0.1]: https://github.com/TomFrost/Jexl/compare/1.0.0...1.0.1
|
|
248
|
-
[v1.0.0]: https://github.com/TomFrost/Jexl/compare/0.2.0...1.0.0
|
|
249
|
-
[v0.2.0]: https://github.com/TomFrost/Jexl/compare/0.1.0...0.2.0
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type Evaluator from './Evaluator.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Evaluates an ArrayLiteral by returning its value, with each element
|
|
4
|
-
* independently run through the evaluator.
|
|
5
|
-
* @param {{type: 'ObjectLiteral', value: <{}>}} ast An expression tree with an
|
|
6
|
-
* ObjectLiteral as the top node
|
|
7
|
-
* @returns {[]} an array of evaluated values.
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
export declare function ArrayLiteral(this: Evaluator, ast: any): any[];
|
|
11
|
-
/**
|
|
12
|
-
* Evaluates a BinaryExpression node by running the Grammar's evaluator for
|
|
13
|
-
* the given operator. Note that binary expressions support two types of
|
|
14
|
-
* evaluators: `eval` is called with the left and right operands pre-evaluated.
|
|
15
|
-
* `evalOnDemand`, if it exists, will be called with the left and right operands
|
|
16
|
-
* each individually wrapped in an object with an "eval" function that returns
|
|
17
|
-
* the resulting value. This allows the binary expression to evaluate the
|
|
18
|
-
* operands conditionally.
|
|
19
|
-
* @param {{type: 'BinaryExpression', operator: <string>, left: {},
|
|
20
|
-
* right: {}}} ast An expression tree with a BinaryExpression as the top
|
|
21
|
-
* node
|
|
22
|
-
* @returns {*} the value of the BinaryExpression.
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
export declare function BinaryExpression(this: Evaluator, ast: any): any;
|
|
26
|
-
/**
|
|
27
|
-
* Evaluates a ConditionalExpression node by first evaluating its test branch,
|
|
28
|
-
* and returning the consequent branch if the test is truthy, or the alternate
|
|
29
|
-
* branch if it is not. If there is no consequent branch, the test result will
|
|
30
|
-
* be used instead.
|
|
31
|
-
* @param {{type: 'ConditionalExpression', test: {}, consequent: {},
|
|
32
|
-
* alternate: {}}} ast An expression tree with a ConditionalExpression as
|
|
33
|
-
* the top node
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
|
-
export declare function ConditionalExpression(this: Evaluator, ast: any): any;
|
|
37
|
-
/**
|
|
38
|
-
* Evaluates a FilterExpression by applying bracket notation for array/object access.
|
|
39
|
-
* Note: Relative filtering (with leading dot) is not supported.
|
|
40
|
-
* @param {{type: 'FilterExpression', relative: <boolean>, expr: {},
|
|
41
|
-
* subject: {}}} ast An expression tree with a FilterExpression as the top
|
|
42
|
-
* node
|
|
43
|
-
* @returns {*} the value at the specified index/property.
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
export declare function FilterExpression(this: Evaluator, ast: any): any;
|
|
47
|
-
/**
|
|
48
|
-
* Evaluates an Identifier by either stemming from the evaluated 'from'
|
|
49
|
-
* expression tree or accessing the context provided when this Evaluator was
|
|
50
|
-
* constructed.
|
|
51
|
-
* @param {{type: 'Identifier', value: <string>, [from]: {}}} ast An expression
|
|
52
|
-
* tree with an Identifier as the top node
|
|
53
|
-
* @returns {*} the identifier's value.
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
export declare function Identifier(this: Evaluator, ast: any): any;
|
|
57
|
-
/**
|
|
58
|
-
* Evaluates a Literal by returning its value property.
|
|
59
|
-
* @param {{type: 'Literal', value: <string|number|boolean>}} ast An expression
|
|
60
|
-
* tree with a Literal as its only node
|
|
61
|
-
* @returns {string|number|boolean} The value of the Literal node
|
|
62
|
-
* @private
|
|
63
|
-
*/
|
|
64
|
-
export declare function Literal(this: Evaluator, ast: any): any;
|
|
65
|
-
/**
|
|
66
|
-
* Evaluates a TemplateLiteral by evaluating each interpolated expression
|
|
67
|
-
* and concatenating all parts into a final string.
|
|
68
|
-
* @param {{type: 'TemplateLiteral', parts: Array<{}>}} ast An expression
|
|
69
|
-
* tree with a TemplateLiteral as the top node
|
|
70
|
-
* @returns {string} the final interpolated string
|
|
71
|
-
* @private
|
|
72
|
-
*/
|
|
73
|
-
export declare function TemplateLiteral(this: Evaluator, ast: any): any;
|
|
74
|
-
/**
|
|
75
|
-
* Evaluates an ObjectLiteral by returning its value, with each key
|
|
76
|
-
* independently run through the evaluator.
|
|
77
|
-
* @param {{type: 'ObjectLiteral', value: <{}>}} ast An expression tree with an
|
|
78
|
-
* ObjectLiteral as the top node
|
|
79
|
-
* @returns {{}} a map of evaluated values.
|
|
80
|
-
* @private
|
|
81
|
-
*/
|
|
82
|
-
export declare function ObjectLiteral(this: Evaluator, ast: any): {
|
|
83
|
-
[k: string]: any;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Evaluates a FunctionCall node by applying the supplied arguments to a
|
|
87
|
-
* function defined in one of the grammar's function pools.
|
|
88
|
-
* @param {{type: 'FunctionCall', name: <string>}} ast An
|
|
89
|
-
* expression tree with a FunctionCall as the top node
|
|
90
|
-
* @returns {*} the value of the function call.
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
export declare function FunctionCall(this: Evaluator, ast: any): any;
|
|
94
|
-
/**
|
|
95
|
-
* Evaluates a Unary expression by passing the right side through the
|
|
96
|
-
* operator's eval function.
|
|
97
|
-
* @param {{type: 'UnaryExpression', operator: <string>, right: {}}} ast An
|
|
98
|
-
* expression tree with a UnaryExpression as the top node
|
|
99
|
-
* @returns {*} the value of the UnaryExpression.
|
|
100
|
-
* @constructor
|
|
101
|
-
*/
|
|
102
|
-
export declare function UnaryExpression(this: Evaluator, ast: any): any;
|
|
103
|
-
/**
|
|
104
|
-
* Evaluates a SequenceExpression by evaluating each expression in order
|
|
105
|
-
* and returning the value of the last expression.
|
|
106
|
-
*/
|
|
107
|
-
export declare function SequenceExpression(this: Evaluator, ast: any): any;
|
|
108
|
-
/**
|
|
109
|
-
* Evaluates an AssignmentExpression by evaluating the right side
|
|
110
|
-
* and assigning it to the variable name on the left side.
|
|
111
|
-
*/
|
|
112
|
-
export declare function AssignmentExpression(this: Evaluator, ast: any): any;
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Jexl
|
|
4
|
-
* Copyright 2020 Tom Shawver
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ArrayLiteral = ArrayLiteral;
|
|
8
|
-
exports.BinaryExpression = BinaryExpression;
|
|
9
|
-
exports.ConditionalExpression = ConditionalExpression;
|
|
10
|
-
exports.FilterExpression = FilterExpression;
|
|
11
|
-
exports.Identifier = Identifier;
|
|
12
|
-
exports.Literal = Literal;
|
|
13
|
-
exports.TemplateLiteral = TemplateLiteral;
|
|
14
|
-
exports.ObjectLiteral = ObjectLiteral;
|
|
15
|
-
exports.FunctionCall = FunctionCall;
|
|
16
|
-
exports.UnaryExpression = UnaryExpression;
|
|
17
|
-
exports.SequenceExpression = SequenceExpression;
|
|
18
|
-
exports.AssignmentExpression = AssignmentExpression;
|
|
19
|
-
const poolNames = {
|
|
20
|
-
functions: 'Jexl Function'
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Evaluates an ArrayLiteral by returning its value, with each element
|
|
24
|
-
* independently run through the evaluator.
|
|
25
|
-
* @param {{type: 'ObjectLiteral', value: <{}>}} ast An expression tree with an
|
|
26
|
-
* ObjectLiteral as the top node
|
|
27
|
-
* @returns {[]} an array of evaluated values.
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
function ArrayLiteral(ast) {
|
|
31
|
-
return this.evalArray(ast.value);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Evaluates a BinaryExpression node by running the Grammar's evaluator for
|
|
35
|
-
* the given operator. Note that binary expressions support two types of
|
|
36
|
-
* evaluators: `eval` is called with the left and right operands pre-evaluated.
|
|
37
|
-
* `evalOnDemand`, if it exists, will be called with the left and right operands
|
|
38
|
-
* each individually wrapped in an object with an "eval" function that returns
|
|
39
|
-
* the resulting value. This allows the binary expression to evaluate the
|
|
40
|
-
* operands conditionally.
|
|
41
|
-
* @param {{type: 'BinaryExpression', operator: <string>, left: {},
|
|
42
|
-
* right: {}}} ast An expression tree with a BinaryExpression as the top
|
|
43
|
-
* node
|
|
44
|
-
* @returns {*} the value of the BinaryExpression.
|
|
45
|
-
* @private
|
|
46
|
-
*/
|
|
47
|
-
function BinaryExpression(ast) {
|
|
48
|
-
const grammarOp = this._grammar.elements[ast.operator];
|
|
49
|
-
if (grammarOp.evalOnDemand) {
|
|
50
|
-
const wrap = (subAst) => ({ eval: () => this.eval(subAst) });
|
|
51
|
-
return grammarOp.evalOnDemand(wrap(ast.left), wrap(ast.right));
|
|
52
|
-
}
|
|
53
|
-
const left = this.eval(ast.left);
|
|
54
|
-
const right = this.eval(ast.right);
|
|
55
|
-
return grammarOp.eval(left, right);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Evaluates a ConditionalExpression node by first evaluating its test branch,
|
|
59
|
-
* and returning the consequent branch if the test is truthy, or the alternate
|
|
60
|
-
* branch if it is not. If there is no consequent branch, the test result will
|
|
61
|
-
* be used instead.
|
|
62
|
-
* @param {{type: 'ConditionalExpression', test: {}, consequent: {},
|
|
63
|
-
* alternate: {}}} ast An expression tree with a ConditionalExpression as
|
|
64
|
-
* the top node
|
|
65
|
-
* @private
|
|
66
|
-
*/
|
|
67
|
-
function ConditionalExpression(ast) {
|
|
68
|
-
const res = this.eval(ast.test);
|
|
69
|
-
if (res) {
|
|
70
|
-
return ast.consequent ? this.eval(ast.consequent) : res;
|
|
71
|
-
}
|
|
72
|
-
return this.eval(ast.alternate);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Evaluates a FilterExpression by applying bracket notation for array/object access.
|
|
76
|
-
* Note: Relative filtering (with leading dot) is not supported.
|
|
77
|
-
* @param {{type: 'FilterExpression', relative: <boolean>, expr: {},
|
|
78
|
-
* subject: {}}} ast An expression tree with a FilterExpression as the top
|
|
79
|
-
* node
|
|
80
|
-
* @returns {*} the value at the specified index/property.
|
|
81
|
-
* @private
|
|
82
|
-
*/
|
|
83
|
-
function FilterExpression(ast) {
|
|
84
|
-
const subject = this.eval(ast.subject);
|
|
85
|
-
if (ast.relative) {
|
|
86
|
-
throw new Error('Relative filter expressions are not supported');
|
|
87
|
-
}
|
|
88
|
-
const index = this.eval(ast.expr);
|
|
89
|
-
return subject?.[index];
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Evaluates an Identifier by either stemming from the evaluated 'from'
|
|
93
|
-
* expression tree or accessing the context provided when this Evaluator was
|
|
94
|
-
* constructed.
|
|
95
|
-
* @param {{type: 'Identifier', value: <string>, [from]: {}}} ast An expression
|
|
96
|
-
* tree with an Identifier as the top node
|
|
97
|
-
* @returns {*} the identifier's value.
|
|
98
|
-
* @private
|
|
99
|
-
*/
|
|
100
|
-
function Identifier(ast) {
|
|
101
|
-
if (!ast.from) {
|
|
102
|
-
const contextSource = ast.relative ? this._relContext : this._context;
|
|
103
|
-
return contextSource[ast.value];
|
|
104
|
-
}
|
|
105
|
-
const context = this.eval(ast.from);
|
|
106
|
-
if (context == null) {
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
const ctx = Array.isArray(context) ? context[0] : context;
|
|
110
|
-
return ctx?.[ast.value];
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Evaluates a Literal by returning its value property.
|
|
114
|
-
* @param {{type: 'Literal', value: <string|number|boolean>}} ast An expression
|
|
115
|
-
* tree with a Literal as its only node
|
|
116
|
-
* @returns {string|number|boolean} The value of the Literal node
|
|
117
|
-
* @private
|
|
118
|
-
*/
|
|
119
|
-
function Literal(ast) {
|
|
120
|
-
return ast.value;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Evaluates a TemplateLiteral by evaluating each interpolated expression
|
|
124
|
-
* and concatenating all parts into a final string.
|
|
125
|
-
* @param {{type: 'TemplateLiteral', parts: Array<{}>}} ast An expression
|
|
126
|
-
* tree with a TemplateLiteral as the top node
|
|
127
|
-
* @returns {string} the final interpolated string
|
|
128
|
-
* @private
|
|
129
|
-
*/
|
|
130
|
-
function TemplateLiteral(ast) {
|
|
131
|
-
const values = ast.parts.map((part) => {
|
|
132
|
-
if (part.type === 'static') {
|
|
133
|
-
return part.value;
|
|
134
|
-
}
|
|
135
|
-
const result = this.eval(part.value);
|
|
136
|
-
if (result == null) {
|
|
137
|
-
return '';
|
|
138
|
-
}
|
|
139
|
-
return String(result);
|
|
140
|
-
});
|
|
141
|
-
return values.join('');
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Evaluates an ObjectLiteral by returning its value, with each key
|
|
145
|
-
* independently run through the evaluator.
|
|
146
|
-
* @param {{type: 'ObjectLiteral', value: <{}>}} ast An expression tree with an
|
|
147
|
-
* ObjectLiteral as the top node
|
|
148
|
-
* @returns {{}} a map of evaluated values.
|
|
149
|
-
* @private
|
|
150
|
-
*/
|
|
151
|
-
function ObjectLiteral(ast) {
|
|
152
|
-
return this.evalMap(ast.value);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Evaluates a FunctionCall node by applying the supplied arguments to a
|
|
156
|
-
* function defined in one of the grammar's function pools.
|
|
157
|
-
* @param {{type: 'FunctionCall', name: <string>}} ast An
|
|
158
|
-
* expression tree with a FunctionCall as the top node
|
|
159
|
-
* @returns {*} the value of the function call.
|
|
160
|
-
* @private
|
|
161
|
-
*/
|
|
162
|
-
function FunctionCall(ast) {
|
|
163
|
-
const poolName = poolNames[ast.pool];
|
|
164
|
-
if (!poolName) {
|
|
165
|
-
throw new Error(`Corrupt AST: Pool '${ast.pool}' not found`);
|
|
166
|
-
}
|
|
167
|
-
const pool = this._grammar[ast.pool];
|
|
168
|
-
const func = pool?.[ast.name];
|
|
169
|
-
if (!func) {
|
|
170
|
-
throw new Error(`${poolName} ${ast.name} is not defined.`);
|
|
171
|
-
}
|
|
172
|
-
const args = this.evalArray(ast.args || []);
|
|
173
|
-
return func(...args);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Evaluates a Unary expression by passing the right side through the
|
|
177
|
-
* operator's eval function.
|
|
178
|
-
* @param {{type: 'UnaryExpression', operator: <string>, right: {}}} ast An
|
|
179
|
-
* expression tree with a UnaryExpression as the top node
|
|
180
|
-
* @returns {*} the value of the UnaryExpression.
|
|
181
|
-
* @constructor
|
|
182
|
-
*/
|
|
183
|
-
function UnaryExpression(ast) {
|
|
184
|
-
const right = this.eval(ast.right);
|
|
185
|
-
return this._grammar.elements[ast.operator].eval(right);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Evaluates a SequenceExpression by evaluating each expression in order
|
|
189
|
-
* and returning the value of the last expression.
|
|
190
|
-
*/
|
|
191
|
-
function SequenceExpression(ast) {
|
|
192
|
-
let lastValue;
|
|
193
|
-
for (const expr of ast.expressions) {
|
|
194
|
-
lastValue = this.eval(expr);
|
|
195
|
-
}
|
|
196
|
-
return lastValue;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Evaluates an AssignmentExpression by evaluating the right side
|
|
200
|
-
* and assigning it to the variable name on the left side.
|
|
201
|
-
*/
|
|
202
|
-
function AssignmentExpression(ast) {
|
|
203
|
-
const value = this.eval(ast.right);
|
|
204
|
-
const varName = ast.left.value;
|
|
205
|
-
this._context[varName] = value;
|
|
206
|
-
return value;
|
|
207
|
-
}
|
|
208
|
-
//# sourceMappingURL=handlers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/evaluator/handlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAiBH,oCAEC;AAgBD,4CASC;AAYD,sDAMC;AAWD,4CAOC;AAWD,gCAWC;AASD,0BAEC;AAUD,0CAaC;AAUD,sCAEC;AAUD,oCAYC;AAUD,0CAGC;AAMD,gDAQC;AAMD,oDAKC;AA3MD,MAAM,SAAS,GAA2B;IACxC,SAAS,EAAE,eAAe;CAC3B,CAAA;AAED;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAkB,GAAQ;IACpD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAAkB,GAAQ;IACxD,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACtD,IAAI,SAAS,CAAC,YAAY,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACrE,OAAO,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IAChE,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAClC,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,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|
|
2
|
-
/**
|
|
3
|
-
* Evaluates an ArrayLiteral by returning its value, with each element
|
|
4
|
-
* independently run through the evaluator.
|
|
5
|
-
* @param {{type: 'ObjectLiteral', value: <{}>}} ast An expression tree with an
|
|
6
|
-
* ObjectLiteral as the top node
|
|
7
|
-
* @returns {[]} an array of evaluated values.
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
export declare function ArrayLiteral(this: Evaluator, ast: any): any[];
|
|
11
|
-
/**
|
|
12
|
-
* Evaluates a BinaryExpression node by running the Grammar's evaluator for
|
|
13
|
-
* the given operator. Note that binary expressions support two types of
|
|
14
|
-
* evaluators: `eval` is called with the left and right operands pre-evaluated.
|
|
15
|
-
* `evalOnDemand`, if it exists, will be called with the left and right operands
|
|
16
|
-
* each individually wrapped in an object with an "eval" function that returns
|
|
17
|
-
* the resulting value. This allows the binary expression to evaluate the
|
|
18
|
-
* operands conditionally.
|
|
19
|
-
* @param {{type: 'BinaryExpression', operator: <string>, left: {},
|
|
20
|
-
* right: {}}} ast An expression tree with a BinaryExpression as the top
|
|
21
|
-
* node
|
|
22
|
-
* @returns {*} the value of the BinaryExpression.
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
export declare function BinaryExpression(this: Evaluator, ast: any): any;
|
|
26
|
-
/**
|
|
27
|
-
* Evaluates a ConditionalExpression node by first evaluating its test branch,
|
|
28
|
-
* and returning the consequent branch if the test is truthy, or the alternate
|
|
29
|
-
* branch if it is not. If there is no consequent branch, the test result will
|
|
30
|
-
* be used instead.
|
|
31
|
-
* @param {{type: 'ConditionalExpression', test: {}, consequent: {},
|
|
32
|
-
* alternate: {}}} ast An expression tree with a ConditionalExpression as
|
|
33
|
-
* the top node
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
|
-
export declare function ConditionalExpression(this: Evaluator, ast: any): any;
|
|
37
|
-
/**
|
|
38
|
-
* Evaluates a FilterExpression by applying bracket notation for array/object access.
|
|
39
|
-
* Note: Relative filtering (with leading dot) is not supported.
|
|
40
|
-
* @param {{type: 'FilterExpression', relative: <boolean>, expr: {},
|
|
41
|
-
* subject: {}}} ast An expression tree with a FilterExpression as the top
|
|
42
|
-
* node
|
|
43
|
-
* @returns {*} the value at the specified index/property.
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
export declare function FilterExpression(this: Evaluator, ast: any): any;
|
|
47
|
-
/**
|
|
48
|
-
* Evaluates an Identifier by either stemming from the evaluated 'from'
|
|
49
|
-
* expression tree or accessing the context provided when this Evaluator was
|
|
50
|
-
* constructed.
|
|
51
|
-
* @param {{type: 'Identifier', value: <string>, [from]: {}}} ast An expression
|
|
52
|
-
* tree with an Identifier as the top node
|
|
53
|
-
* @returns {*} the identifier's value.
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
export declare function Identifier(this: Evaluator, ast: any): any;
|
|
57
|
-
/**
|
|
58
|
-
* Evaluates a Literal by returning its value property.
|
|
59
|
-
* @param {{type: 'Literal', value: <string|number|boolean>}} ast An expression
|
|
60
|
-
* tree with a Literal as its only node
|
|
61
|
-
* @returns {string|number|boolean} The value of the Literal node
|
|
62
|
-
* @private
|
|
63
|
-
*/
|
|
64
|
-
export declare function Literal(this: Evaluator, ast: any): any;
|
|
65
|
-
/**
|
|
66
|
-
* Evaluates a TemplateLiteral by evaluating each interpolated expression
|
|
67
|
-
* and concatenating all parts into a final string.
|
|
68
|
-
* @param {{type: 'TemplateLiteral', parts: Array<{}>}} ast An expression
|
|
69
|
-
* tree with a TemplateLiteral as the top node
|
|
70
|
-
* @returns {string} the final interpolated string
|
|
71
|
-
* @private
|
|
72
|
-
*/
|
|
73
|
-
export declare function TemplateLiteral(this: Evaluator, ast: any): any;
|
|
74
|
-
/**
|
|
75
|
-
* Evaluates an ObjectLiteral by returning its value, with each key
|
|
76
|
-
* independently run through the evaluator.
|
|
77
|
-
* @param {{type: 'ObjectLiteral', value: <{}>}} ast An expression tree with an
|
|
78
|
-
* ObjectLiteral as the top node
|
|
79
|
-
* @returns {{}} a map of evaluated values.
|
|
80
|
-
* @private
|
|
81
|
-
*/
|
|
82
|
-
export declare function ObjectLiteral(this: Evaluator, ast: any): {
|
|
83
|
-
[k: string]: any;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Evaluates a FunctionCall node by applying the supplied arguments to a
|
|
87
|
-
* function defined in one of the grammar's function pools.
|
|
88
|
-
* @param {{type: 'FunctionCall', name: <string>}} ast An
|
|
89
|
-
* expression tree with a FunctionCall as the top node
|
|
90
|
-
* @returns {*} the value of the function call.
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
export declare function FunctionCall(this: Evaluator, ast: any): any;
|
|
94
|
-
/**
|
|
95
|
-
* Evaluates a Unary expression by passing the right side through the
|
|
96
|
-
* operator's eval function.
|
|
97
|
-
* @param {{type: 'UnaryExpression', operator: <string>, right: {}}} ast An
|
|
98
|
-
* expression tree with a UnaryExpression as the top node
|
|
99
|
-
* @returns {*} the value of the UnaryExpression.
|
|
100
|
-
* @constructor
|
|
101
|
-
*/
|
|
102
|
-
export declare function UnaryExpression(this: Evaluator, ast: any): any;
|
|
103
|
-
/**
|
|
104
|
-
* Evaluates a SequenceExpression by evaluating each expression in order
|
|
105
|
-
* and returning the value of the last expression.
|
|
106
|
-
*/
|
|
107
|
-
export declare function SequenceExpression(this: Evaluator, ast: any): any;
|
|
108
|
-
/**
|
|
109
|
-
* Evaluates an AssignmentExpression by evaluating the right side
|
|
110
|
-
* and assigning it to the variable name on the left side.
|
|
111
|
-
*/
|
|
112
|
-
export declare function AssignmentExpression(this: Evaluator, ast: any): any;
|