@@ -19,38 +19,38 @@ export type Operators =
1919 | LogicalOperators
2020 | MembershipOperators ;
2121
22- export const OperatorsMap : Record < Operators , OperationTypes > = {
23- '+' : OperationTypes . Arithmetic ,
24- '-' : OperationTypes . Arithmetic ,
25- '*' : OperationTypes . Arithmetic ,
26- '/' : OperationTypes . Arithmetic ,
27- '%' : OperationTypes . Arithmetic ,
28- '**' : OperationTypes . Arithmetic ,
29- '//' : OperationTypes . Arithmetic ,
30-
31- '>' : OperationTypes . Comparison ,
32- '>=' : OperationTypes . Comparison ,
33- '==' : OperationTypes . Comparison ,
34- '!=' : OperationTypes . Comparison ,
35- '<>' : OperationTypes . Comparison ,
36- '<' : OperationTypes . Comparison ,
37- '<=' : OperationTypes . Comparison ,
38-
39- and : OperationTypes . Logical ,
40- or : OperationTypes . Logical ,
41- // "not": OperationTypes.Logical,
42- // "not in": OperationTypes.Logical,
43-
44- in : OperationTypes . Membership ,
45-
46- '=' : OperationTypes . Assignment ,
47- '+=' : OperationTypes . Assignment ,
48- '-=' : OperationTypes . Assignment ,
49- '*=' : OperationTypes . Assignment ,
50- '/=' : OperationTypes . Assignment ,
51- '++' : OperationTypes . Assignment ,
52- '--' : OperationTypes . Assignment
53- } ;
22+ export const OperatorsMap : Map < Operators , OperationTypes > = new Map < Operators , OperationTypes > ( [
23+ [ '+' , OperationTypes . Arithmetic ] ,
24+ [ '-' , OperationTypes . Arithmetic ] ,
25+ [ '*' , OperationTypes . Arithmetic ] ,
26+ [ '/' , OperationTypes . Arithmetic ] ,
27+ [ '%' , OperationTypes . Arithmetic ] ,
28+ [ '**' , OperationTypes . Arithmetic ] ,
29+ [ '//' , OperationTypes . Arithmetic ] ,
30+
31+ [ '>' , OperationTypes . Comparison ] ,
32+ [ '>=' , OperationTypes . Comparison ] ,
33+ [ '==' , OperationTypes . Comparison ] ,
34+ [ '!=' , OperationTypes . Comparison ] ,
35+ [ '<>' , OperationTypes . Comparison ] ,
36+ [ '<' , OperationTypes . Comparison ] ,
37+ [ '<=' , OperationTypes . Comparison ] ,
38+
39+ [ ' and' , OperationTypes . Logical ] ,
40+ [ 'or' , OperationTypes . Logical ] ,
41+ // "not", OperationTypes.Logical] ,
42+ // "not in", OperationTypes.Logical] ,
43+
44+ [ 'in' , OperationTypes . Membership ] ,
45+
46+ [ '=' , OperationTypes . Assignment ] ,
47+ [ '+=' , OperationTypes . Assignment ] ,
48+ [ '-=' , OperationTypes . Assignment ] ,
49+ [ '*=' , OperationTypes . Assignment ] ,
50+ [ '/=' , OperationTypes . Assignment ] ,
51+ [ '++' , OperationTypes . Assignment ] ,
52+ [ '--' , OperationTypes . Assignment ]
53+ ] ) ;
5454
5555export type Primitive = string | number | boolean | null ;
5656
@@ -61,30 +61,48 @@ export type ExpressionOperators =
6161 | MembershipOperators ;
6262type ExpressionOperation = ( l : Primitive , r : Primitive ) => Primitive ;
6363
64- export const OperationFuncs : Record < ExpressionOperators , ExpressionOperation > = {
65- '+' : ( l , r ) => arithmeticOperation ( l , r , '+' ) ,
66- '-' : ( l , r ) => arithmeticOperation ( l , r , '-' ) ,
67- '/' : ( l , r ) => arithmeticOperation ( l , r , '/' ) ,
68- '*' : ( l , r ) => arithmeticOperation ( l , r , '*' ) ,
69- '%' : ( l , r ) => arithmeticOperation ( l , r , '%' ) ,
70- '**' : ( l , r ) => arithmeticOperation ( l , r , '**' ) ,
71- '//' : ( l , r ) => arithmeticOperation ( l , r , '//' ) ,
72-
73- '>' : ( l , r ) => comparissonOperation ( l , r , '>' ) ,
74- '>=' : ( l , r ) => comparissonOperation ( l , r , '>=' ) ,
75- '<' : ( l , r ) => comparissonOperation ( l , r , '<' ) ,
76- '<=' : ( l , r ) => comparissonOperation ( l , r , '<=' ) ,
77- '==' : ( l , r ) => comparissonOperation ( l , r , '==' ) ,
78- '!=' : ( l , r ) => comparissonOperation ( l , r , '!=' ) ,
79- '<>' : ( l , r ) => comparissonOperation ( l , r , '<>' ) ,
80-
81- and : ( l , r ) => logicalOperation ( l , r , 'and' ) ,
82- or : ( l , r ) => logicalOperation ( l , r , 'or' ) ,
83- // "not": (l, r) => logicalOperation(l, r, "not"),
84- // "not in": (l, r) => logicalOperation(l, r, "not in"),
85-
86- in : ( l , r ) => membershipOperation ( l , r , 'in' )
87- } ;
64+ export const OperationFuncs : Map < ExpressionOperators , ExpressionOperation > = new Map <
65+ ExpressionOperators ,
66+ ExpressionOperation
67+ > ( [
68+ [ '+' as ExpressionOperators , ( ( l , r ) => arithmeticOperation ( l , r , '+' ) ) as ExpressionOperation ] ,
69+ [ '-' as ExpressionOperators , ( ( l , r ) => arithmeticOperation ( l , r , '-' ) ) as ExpressionOperation ] ,
70+ [ '/' as ExpressionOperators , ( ( l , r ) => arithmeticOperation ( l , r , '/' ) ) as ExpressionOperation ] ,
71+ [ '*' as ExpressionOperators , ( ( l , r ) => arithmeticOperation ( l , r , '*' ) ) as ExpressionOperation ] ,
72+ [ '%' as ExpressionOperators , ( ( l , r ) => arithmeticOperation ( l , r , '%' ) ) as ExpressionOperation ] ,
73+ [ '**' as ExpressionOperators , ( ( l , r ) => arithmeticOperation ( l , r , '**' ) ) as ExpressionOperation ] ,
74+ [ '//' as ExpressionOperators , ( ( l , r ) => arithmeticOperation ( l , r , '//' ) ) as ExpressionOperation ] ,
75+
76+ [ '>' as ExpressionOperators , ( ( l , r ) => comparissonOperation ( l , r , '>' ) ) as ExpressionOperation ] ,
77+ [
78+ '>=' as ExpressionOperators ,
79+ ( ( l , r ) => comparissonOperation ( l , r , '>=' ) ) as ExpressionOperation
80+ ] ,
81+ [ '<' as ExpressionOperators , ( ( l , r ) => comparissonOperation ( l , r , '<' ) ) as ExpressionOperation ] ,
82+ [
83+ '<=' as ExpressionOperators ,
84+ ( ( l , r ) => comparissonOperation ( l , r , '<=' ) ) as ExpressionOperation
85+ ] ,
86+ [
87+ '==' as ExpressionOperators ,
88+ ( ( l , r ) => comparissonOperation ( l , r , '==' ) ) as ExpressionOperation
89+ ] ,
90+ [
91+ '!=' as ExpressionOperators ,
92+ ( ( l , r ) => comparissonOperation ( l , r , '!=' ) ) as ExpressionOperation
93+ ] ,
94+ [
95+ '<>' as ExpressionOperators ,
96+ ( ( l , r ) => comparissonOperation ( l , r , '<>' ) ) as ExpressionOperation
97+ ] ,
98+
99+ [ 'and' as ExpressionOperators , ( ( l , r ) => logicalOperation ( l , r , 'and' ) ) as ExpressionOperation ] ,
100+ [ 'or' as ExpressionOperators , ( ( l , r ) => logicalOperation ( l , r , 'or' ) ) as ExpressionOperation ] ,
101+ // "not" as ExpressionOperators, ((l, r) => logicalOperation(l, r, "not")) as ExpressionOperation],
102+ // "not in" as ExpressionOperators, ((l, r) => logicalOperation(l, r, "not in")) as ExpressionOperation],
103+
104+ [ 'in' as ExpressionOperators , ( ( l , r ) => membershipOperation ( l , r , 'in' ) ) as ExpressionOperation ]
105+ ] ) ;
88106
89107function membershipOperation ( l : Primitive , r : Primitive , op : MembershipOperators ) : Primitive {
90108 if ( typeof l === 'string' ) {
0 commit comments