@jbrowse/jexl 3.2.0 → 4.0.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.
Files changed (63) hide show
  1. package/dist/Expression.js +1 -2
  2. package/dist/Expression.js.map +1 -1
  3. package/dist/Jexl.d.ts +8 -8
  4. package/dist/Jexl.js +7 -1
  5. package/dist/Jexl.js.map +1 -1
  6. package/dist/Lexer.d.ts +10 -8
  7. package/dist/Lexer.js +46 -35
  8. package/dist/Lexer.js.map +1 -1
  9. package/dist/evaluator/compile.d.ts +6 -4
  10. package/dist/evaluator/compile.js +42 -52
  11. package/dist/evaluator/compile.js.map +1 -1
  12. package/dist/grammar.d.ts +19 -2
  13. package/dist/grammar.js +1 -1
  14. package/dist/grammar.js.map +1 -1
  15. package/dist/parser/Parser.d.ts +2 -9
  16. package/dist/parser/Parser.js +2 -12
  17. package/dist/parser/Parser.js.map +1 -1
  18. package/dist/parser/handlers.d.ts +6 -3
  19. package/dist/parser/handlers.js +45 -28
  20. package/dist/parser/handlers.js.map +1 -1
  21. package/dist/parser/states.js +3 -5
  22. package/dist/parser/states.js.map +1 -1
  23. package/dist/types.d.ts +0 -3
  24. package/esm/Expression.js +1 -2
  25. package/esm/Expression.js.map +1 -1
  26. package/esm/Jexl.d.ts +8 -8
  27. package/esm/Jexl.js +7 -1
  28. package/esm/Jexl.js.map +1 -1
  29. package/esm/Lexer.d.ts +10 -8
  30. package/esm/Lexer.js +46 -35
  31. package/esm/Lexer.js.map +1 -1
  32. package/esm/evaluator/compile.d.ts +6 -4
  33. package/esm/evaluator/compile.js +42 -52
  34. package/esm/evaluator/compile.js.map +1 -1
  35. package/esm/grammar.d.ts +19 -2
  36. package/esm/grammar.js +1 -1
  37. package/esm/grammar.js.map +1 -1
  38. package/esm/parser/Parser.d.ts +2 -9
  39. package/esm/parser/Parser.js +2 -12
  40. package/esm/parser/Parser.js.map +1 -1
  41. package/esm/parser/handlers.d.ts +6 -3
  42. package/esm/parser/handlers.js +45 -28
  43. package/esm/parser/handlers.js.map +1 -1
  44. package/esm/parser/states.js +3 -5
  45. package/esm/parser/states.js.map +1 -1
  46. package/esm/types.d.ts +0 -3
  47. package/package.json +2 -1
  48. package/src/Expression.ts +1 -2
  49. package/src/Jexl.ts +20 -11
  50. package/src/Lexer.ts +47 -36
  51. package/src/evaluator/compile.ts +53 -68
  52. package/src/grammar.ts +23 -3
  53. package/src/parser/Parser.ts +2 -13
  54. package/src/parser/handlers.ts +48 -31
  55. package/src/parser/states.ts +3 -5
  56. package/src/types.ts +0 -3
  57. package/dist/evaluator/Evaluator.d.ts +0 -37
  58. package/dist/evaluator/Evaluator.js +0 -49
  59. package/dist/evaluator/Evaluator.js.map +0 -1
  60. package/esm/evaluator/Evaluator.d.ts +0 -37
  61. package/esm/evaluator/Evaluator.js +0 -47
  62. package/esm/evaluator/Evaluator.js.map +0 -1
  63. package/src/evaluator/Evaluator.ts +0 -58
@@ -1,37 +0,0 @@
1
- import type { Grammar } from '../grammar.ts';
2
- import type { AstNode, JexlValue } from '../types.ts';
3
- /**
4
- * The Evaluator carries everything an expression is evaluated against: the
5
- * grammar, the context, and a relative context to be used as the root for
6
- * relative identifiers. When any of these change, a new instance is required.
7
- * However, a single instance can be used to evaluate many different
8
- * expressions, and does not have to be reinstantiated for each.
9
- *
10
- * The work of evaluation itself lives in {@link compileAst}, which lowers a
11
- * tree to closures. Prefer compiling once and reusing the result — that is what
12
- * {@link Expression} does — over calling {@link #eval}, which compiles the tree
13
- * it is given every time.
14
- *
15
- * @param {{}} grammar A grammar object against which to evaluate the expression
16
- * tree
17
- * @param {{}} [context] A map of variable keys to their values. This will be
18
- * accessed to resolve the value of each non-relative identifier.
19
- * @param {{}|Array<{}|Array>} [relativeContext] A map or array to be accessed
20
- * to resolve the value of a relative identifier.
21
- */
22
- declare class Evaluator {
23
- _grammar: Grammar;
24
- _context: Record<string, JexlValue>;
25
- _relContext: Record<string, JexlValue>;
26
- constructor(grammar: Grammar, context?: Record<string, JexlValue>, relativeContext?: Record<string, JexlValue>);
27
- /**
28
- * Compiles and evaluates an expression tree within the configured context.
29
- * Convenient for a one-shot evaluation; for repeated evaluation of the same
30
- * tree, hold onto the closure from {@link compileAst} instead so the tree is
31
- * only lowered once.
32
- * @param {{}} ast An expression tree object
33
- * @returns {*} the resulting value of the expression.
34
- */
35
- eval(ast: AstNode): JexlValue;
36
- }
37
- export default Evaluator;
@@ -1,47 +0,0 @@
1
- /*
2
- * Jexl
3
- * Copyright 2020 Tom Shawver
4
- */
5
- import { compileAst } from "./compile.js";
6
- /**
7
- * The Evaluator carries everything an expression is evaluated against: the
8
- * grammar, the context, and a relative context to be used as the root for
9
- * relative identifiers. When any of these change, a new instance is required.
10
- * However, a single instance can be used to evaluate many different
11
- * expressions, and does not have to be reinstantiated for each.
12
- *
13
- * The work of evaluation itself lives in {@link compileAst}, which lowers a
14
- * tree to closures. Prefer compiling once and reusing the result — that is what
15
- * {@link Expression} does — over calling {@link #eval}, which compiles the tree
16
- * it is given every time.
17
- *
18
- * @param {{}} grammar A grammar object against which to evaluate the expression
19
- * tree
20
- * @param {{}} [context] A map of variable keys to their values. This will be
21
- * accessed to resolve the value of each non-relative identifier.
22
- * @param {{}|Array<{}|Array>} [relativeContext] A map or array to be accessed
23
- * to resolve the value of a relative identifier.
24
- */
25
- class Evaluator {
26
- _grammar;
27
- _context;
28
- _relContext;
29
- constructor(grammar, context, relativeContext) {
30
- this._grammar = grammar;
31
- this._context = context || {};
32
- this._relContext = relativeContext || this._context;
33
- }
34
- /**
35
- * Compiles and evaluates an expression tree within the configured context.
36
- * Convenient for a one-shot evaluation; for repeated evaluation of the same
37
- * tree, hold onto the closure from {@link compileAst} instead so the tree is
38
- * only lowered once.
39
- * @param {{}} ast An expression tree object
40
- * @returns {*} the resulting value of the expression.
41
- */
42
- eval(ast) {
43
- return compileAst(ast, this._grammar)(this);
44
- }
45
- }
46
- export default Evaluator;
47
- //# sourceMappingURL=Evaluator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Evaluator.js","sourceRoot":"","sources":["../../src/evaluator/Evaluator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAKzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,SAAS;IACb,QAAQ,CAAS;IACjB,QAAQ,CAA2B;IACnC,WAAW,CAA2B;IAEtC,YACE,OAAgB,EAChB,OAAmC,EACnC,eAA2C;QAE3C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,EAAE,CAAA;QAC7B,IAAI,CAAC,WAAW,GAAG,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAA;IACrD,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,GAAY;QACf,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;IAC7C,CAAC;CACF;AAED,eAAe,SAAS,CAAA"}
@@ -1,58 +0,0 @@
1
- /*
2
- * Jexl
3
- * Copyright 2020 Tom Shawver
4
- */
5
-
6
- import { compileAst } from './compile.ts'
7
-
8
- import type { Grammar } from '../grammar.ts'
9
- import type { AstNode, JexlValue } from '../types.ts'
10
-
11
- /**
12
- * The Evaluator carries everything an expression is evaluated against: the
13
- * grammar, the context, and a relative context to be used as the root for
14
- * relative identifiers. When any of these change, a new instance is required.
15
- * However, a single instance can be used to evaluate many different
16
- * expressions, and does not have to be reinstantiated for each.
17
- *
18
- * The work of evaluation itself lives in {@link compileAst}, which lowers a
19
- * tree to closures. Prefer compiling once and reusing the result — that is what
20
- * {@link Expression} does — over calling {@link #eval}, which compiles the tree
21
- * it is given every time.
22
- *
23
- * @param {{}} grammar A grammar object against which to evaluate the expression
24
- * tree
25
- * @param {{}} [context] A map of variable keys to their values. This will be
26
- * accessed to resolve the value of each non-relative identifier.
27
- * @param {{}|Array<{}|Array>} [relativeContext] A map or array to be accessed
28
- * to resolve the value of a relative identifier.
29
- */
30
- class Evaluator {
31
- _grammar: Grammar
32
- _context: Record<string, JexlValue>
33
- _relContext: Record<string, JexlValue>
34
-
35
- constructor(
36
- grammar: Grammar,
37
- context?: Record<string, JexlValue>,
38
- relativeContext?: Record<string, JexlValue>
39
- ) {
40
- this._grammar = grammar
41
- this._context = context || {}
42
- this._relContext = relativeContext || this._context
43
- }
44
-
45
- /**
46
- * Compiles and evaluates an expression tree within the configured context.
47
- * Convenient for a one-shot evaluation; for repeated evaluation of the same
48
- * tree, hold onto the closure from {@link compileAst} instead so the tree is
49
- * only lowered once.
50
- * @param {{}} ast An expression tree object
51
- * @returns {*} the resulting value of the expression.
52
- */
53
- eval(ast: AstNode): JexlValue {
54
- return compileAst(ast, this._grammar)(this)
55
- }
56
- }
57
-
58
- export default Evaluator