@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.
- package/CHANGELOG.md +27 -0
- package/LICENSE.txt +1 -0
- package/README.md +77 -85
- package/dist/Expression.d.ts +2 -12
- package/dist/Expression.js +5 -27
- package/dist/Expression.js.map +1 -1
- package/dist/Jexl.d.ts +6 -40
- package/dist/Jexl.js +7 -49
- package/dist/Jexl.js.map +1 -1
- package/dist/Lexer.js +3 -1
- package/dist/Lexer.js.map +1 -1
- package/dist/evaluator/Evaluator.d.ts +14 -55
- package/dist/evaluator/Evaluator.js +14 -73
- package/dist/evaluator/Evaluator.js.map +1 -1
- package/dist/evaluator/handlers.d.ts +19 -18
- package/dist/evaluator/handlers.js +54 -62
- package/dist/evaluator/handlers.js.map +1 -1
- package/dist/grammar.d.ts +3 -4
- package/dist/grammar.js +16 -39
- package/dist/grammar.js.map +1 -1
- package/dist/parser/Parser.js +16 -3
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/states.js +7 -3
- package/dist/parser/states.js.map +1 -1
- package/esm/Expression.d.ts +2 -12
- package/esm/Expression.js +5 -27
- package/esm/Expression.js.map +1 -1
- package/esm/Jexl.d.ts +6 -40
- package/esm/Jexl.js +7 -49
- package/esm/Jexl.js.map +1 -1
- package/esm/Lexer.js +3 -1
- package/esm/Lexer.js.map +1 -1
- package/esm/evaluator/Evaluator.d.ts +14 -55
- package/esm/evaluator/Evaluator.js +14 -73
- package/esm/evaluator/Evaluator.js.map +1 -1
- package/esm/evaluator/handlers.d.ts +19 -18
- package/esm/evaluator/handlers.js +54 -62
- package/esm/evaluator/handlers.js.map +1 -1
- package/esm/grammar.d.ts +3 -4
- package/esm/grammar.js +16 -39
- package/esm/grammar.js.map +1 -1
- package/esm/parser/Parser.js +16 -3
- package/esm/parser/Parser.js.map +1 -1
- package/esm/parser/states.js +7 -3
- package/esm/parser/states.js.map +1 -1
- package/package.json +10 -8
- package/src/Expression.ts +5 -36
- package/src/Jexl.ts +7 -54
- package/src/Lexer.ts +3 -1
- package/src/evaluator/Evaluator.ts +14 -92
- package/src/evaluator/handlers.ts +54 -68
- package/src/grammar.ts +17 -38
- package/src/parser/Parser.ts +13 -3
- package/src/parser/states.ts +7 -3
- package/src/types.ts +4 -1
- package/dist/PromiseSync.d.ts +0 -13
- package/dist/PromiseSync.js +0 -80
- package/dist/PromiseSync.js.map +0 -1
- package/esm/PromiseSync.d.ts +0 -13
- package/esm/PromiseSync.js +0 -78
- package/esm/PromiseSync.js.map +0 -1
- package/src/PromiseSync.ts +0 -86
package/src/PromiseSync.ts
DELETED
|
@@ -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
|