@jbrowse/jexl 2.3.1 → 3.0.2

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 (62) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE.txt +1 -0
  3. package/README.md +77 -85
  4. package/dist/Expression.d.ts +2 -12
  5. package/dist/Expression.js +5 -27
  6. package/dist/Expression.js.map +1 -1
  7. package/dist/Jexl.d.ts +6 -40
  8. package/dist/Jexl.js +7 -49
  9. package/dist/Jexl.js.map +1 -1
  10. package/dist/Lexer.js +3 -1
  11. package/dist/Lexer.js.map +1 -1
  12. package/dist/evaluator/Evaluator.d.ts +14 -55
  13. package/dist/evaluator/Evaluator.js +14 -73
  14. package/dist/evaluator/Evaluator.js.map +1 -1
  15. package/dist/evaluator/handlers.d.ts +19 -18
  16. package/dist/evaluator/handlers.js +54 -62
  17. package/dist/evaluator/handlers.js.map +1 -1
  18. package/dist/grammar.d.ts +3 -4
  19. package/dist/grammar.js +16 -39
  20. package/dist/grammar.js.map +1 -1
  21. package/dist/parser/Parser.js +16 -3
  22. package/dist/parser/Parser.js.map +1 -1
  23. package/dist/parser/states.js +7 -3
  24. package/dist/parser/states.js.map +1 -1
  25. package/esm/Expression.d.ts +2 -12
  26. package/esm/Expression.js +5 -27
  27. package/esm/Expression.js.map +1 -1
  28. package/esm/Jexl.d.ts +6 -40
  29. package/esm/Jexl.js +7 -49
  30. package/esm/Jexl.js.map +1 -1
  31. package/esm/Lexer.js +3 -1
  32. package/esm/Lexer.js.map +1 -1
  33. package/esm/evaluator/Evaluator.d.ts +14 -55
  34. package/esm/evaluator/Evaluator.js +14 -73
  35. package/esm/evaluator/Evaluator.js.map +1 -1
  36. package/esm/evaluator/handlers.d.ts +19 -18
  37. package/esm/evaluator/handlers.js +54 -62
  38. package/esm/evaluator/handlers.js.map +1 -1
  39. package/esm/grammar.d.ts +3 -4
  40. package/esm/grammar.js +16 -39
  41. package/esm/grammar.js.map +1 -1
  42. package/esm/parser/Parser.js +16 -3
  43. package/esm/parser/Parser.js.map +1 -1
  44. package/esm/parser/states.js +7 -3
  45. package/esm/parser/states.js.map +1 -1
  46. package/package.json +10 -8
  47. package/src/Expression.ts +5 -36
  48. package/src/Jexl.ts +7 -54
  49. package/src/Lexer.ts +3 -1
  50. package/src/evaluator/Evaluator.ts +14 -92
  51. package/src/evaluator/handlers.ts +54 -68
  52. package/src/grammar.ts +17 -38
  53. package/src/parser/Parser.ts +13 -3
  54. package/src/parser/states.ts +7 -3
  55. package/src/types.ts +4 -1
  56. package/dist/PromiseSync.d.ts +0 -13
  57. package/dist/PromiseSync.js +0 -80
  58. package/dist/PromiseSync.js.map +0 -1
  59. package/esm/PromiseSync.d.ts +0 -13
  60. package/esm/PromiseSync.js +0 -78
  61. package/esm/PromiseSync.js.map +0 -1
  62. package/src/PromiseSync.ts +0 -86
@@ -1,86 +0,0 @@
1
- /*
2
- * Jexl
3
- * Copyright 2020 Tom Shawver
4
- */
5
-
6
- class PromiseSync<T = unknown> {
7
- value?: T
8
- error?: unknown
9
-
10
- constructor(fn: (resolve: (val: T) => void, reject: (error: unknown) => void) => void) {
11
- fn(this._resolve.bind(this), this._reject.bind(this))
12
- }
13
-
14
- catch<TResult = never>(rejected: (error: unknown) => TResult): PromiseSync<T | TResult> {
15
- if (this.error) {
16
- try {
17
- this._resolve(rejected(this.error) as any)
18
- } catch (e) {
19
- this._reject(e)
20
- }
21
- }
22
- return this as any
23
- }
24
-
25
- // eslint-disable-next-line unicorn/no-thenable
26
- then<TResult1 = T, TResult2 = never>(
27
- resolved: (val: T) => TResult1,
28
- rejected?: (error: unknown) => TResult2
29
- ): PromiseSync<TResult1 | TResult2> {
30
- if (!this.error) {
31
- try {
32
- this._resolve(resolved(this.value as T) as any)
33
- } catch (e) {
34
- this._reject(e)
35
- }
36
- }
37
- if (rejected) {this.catch(rejected)}
38
- return this as any
39
- }
40
-
41
- _reject(error: unknown) {
42
- this.value = undefined
43
- this.error = error
44
- }
45
-
46
- _resolve(val: any) {
47
- if (val instanceof PromiseSync) {
48
- if (val.error) {
49
- this._reject(val.error)
50
- } else {
51
- this._resolve(val.value)
52
- }
53
- } else {
54
- this.value = val
55
- this.error = undefined
56
- }
57
- }
58
-
59
- static all<T>(vals: (PromiseSync<T> | T)[]): PromiseSync<T[]> {
60
- return new PromiseSync((resolve) => {
61
- const resolved = vals.map((val) => {
62
- while (val instanceof PromiseSync) {
63
- if (val.error) {
64
- if (val.error instanceof Error) {
65
- throw val.error
66
- }
67
- throw new Error(typeof val.error === 'string' ? val.error : JSON.stringify(val.error))
68
- }
69
- val = val.value as T
70
- }
71
- return val
72
- })
73
- resolve(resolved)
74
- })
75
- }
76
-
77
- static resolve<T>(val?: T): PromiseSync<T> {
78
- return new PromiseSync<T>((resolve) => { resolve(val as T) })
79
- }
80
-
81
- static reject(error: unknown): PromiseSync<never> {
82
- return new PromiseSync((_, reject) => { reject(error) })
83
- }
84
- }
85
-
86
- export default PromiseSync