@@ -12,94 +12,94 @@ import {
12
12
RegexiCompareOp ,
13
13
NotCompareOp ,
14
14
NotEqualCompareOp ,
15
- OrCompareOp , InqCompareOp , NinCompareOp , RuleFunctionsTable , RuleFunctionsParams
16
- } from '../types' ;
15
+ OrCompareOp , InqCompareOp , NinCompareOp , RuleFunctionsTable , RuleFunctionsParams , Primitive
16
+ } from '../types' ;
17
17
18
- export const _isObject = ( obj : unknown ) : boolean => {
18
+ export const _isObject = ( obj : unknown ) : boolean => {
19
19
const type = typeof obj ;
20
20
return type === 'function' || type === 'object' && ! ! obj ;
21
- } ;
21
+ } ;
22
22
23
- export const isFunctionCompareOp =
23
+ export const isFunctionCompareOp =
24
24
< C extends Context , F extends FunctionsTable < C > , Ignore > ( expression : unknown , functionsTable : F , key : string ) :
25
- expression is FuncCompares < C , F > => {
26
- return key in functionsTable ;
25
+ expression is FuncCompares < C , F > => {
26
+ return key in functionsTable ;
27
27
}
28
28
29
- export const isRuleFunction =
29
+ export const isRuleFunction =
30
30
< ConsequencePayload , C extends Context , RF extends RuleFunctionsTable < C , ConsequencePayload > > (
31
- expression : unknown , ruleFunctionsTable : RF , key : string ) :
32
- expression is RuleFunctionsParams < ConsequencePayload , C , RF > => {
33
- return key in ruleFunctionsTable ;
31
+ expression : unknown , ruleFunctionsTable : RF , key : string ) :
32
+ expression is RuleFunctionsParams < ConsequencePayload , C , RF > => {
33
+ return key in ruleFunctionsTable ;
34
34
}
35
35
36
- export const isAndCompareOp =
36
+ export const isAndCompareOp =
37
37
< C extends Context , F extends FunctionsTable < C > , Ignore > ( expression : unknown ) :
38
- expression is AndCompareOp < C , F , Ignore > => {
39
- return Array . isArray ( ( expression as AndCompareOp < C , F , Ignore > ) . and ) ;
38
+ expression is AndCompareOp < C , F , Ignore > => {
39
+ return Array . isArray ( ( expression as AndCompareOp < C , F , Ignore > ) . and ) ;
40
40
}
41
41
42
- export const isOrCompareOp = < C extends Context , F extends FunctionsTable < C > , Ignore > ( expression : unknown ) :
42
+ export const isOrCompareOp = < C extends Context , F extends FunctionsTable < C > , Ignore > ( expression : unknown ) :
43
43
expression is OrCompareOp < C , F , Ignore > => {
44
44
return Array . isArray ( ( expression as OrCompareOp < C , F , Ignore > ) . or ) ;
45
- }
45
+ }
46
46
47
- export const isNotCompareOp = < C extends Context , F extends FunctionsTable < C > , Ignore > ( expression : unknown ) :
47
+ export const isNotCompareOp = < C extends Context , F extends FunctionsTable < C > , Ignore > ( expression : unknown ) :
48
48
expression is NotCompareOp < C , F , Ignore > => {
49
49
return _isObject ( ( expression as NotCompareOp < C , F , Ignore > ) . not ) ;
50
- }
51
-
52
- export const isBetweenCompareOp = ( op : ExtendedCompareOp )
53
- : op is BetweenCompareOp => {
54
- return Array . isArray ( ( op as BetweenCompareOp ) . between ) ;
55
- }
56
-
57
- export const isGtCompareOp = ( op : ExtendedCompareOp )
58
- : op is GtCompareOp => {
59
- return ( op as GtCompareOp ) . gt !== undefined ;
60
- }
61
-
62
- export const isGteCompareOp = ( op : ExtendedCompareOp )
63
- : op is GteCompareOp => {
64
- return ( op as GteCompareOp ) . gte !== undefined ;
65
- }
66
-
67
- export const isLteCompareOp = ( op : ExtendedCompareOp )
68
- : op is LteCompareOp => {
69
- return ( op as LteCompareOp ) . lte !== undefined ;
70
- }
71
-
72
- export const isLtCompareOp = ( op : ExtendedCompareOp )
73
- : op is LtCompareOp => {
74
- return ( op as LtCompareOp ) . lt !== undefined ;
75
- }
76
-
77
- export const isRegexCompareOp = ( op : ExtendedCompareOp )
78
- : op is RegexCompareOp => {
79
- return ( op as RegexCompareOp ) . regexp !== undefined ;
80
- }
81
-
82
- export const isRegexiCompareOp = ( op : ExtendedCompareOp )
83
- : op is RegexiCompareOp => {
84
- return ( op as RegexiCompareOp ) . regexpi !== undefined ;
85
- }
86
-
87
- export const isEqualCompareOp = < V > ( op : ExtendedCompareOp )
88
- : op is EqualCompareOp < V > => {
89
- return ( op as EqualCompareOp < V > ) . eq !== undefined ;
90
- }
91
-
92
- export const isNotEqualCompareOp = < V > ( op : ExtendedCompareOp )
93
- : op is NotEqualCompareOp < V > => {
94
- return ( op as NotEqualCompareOp < V > ) . neq !== undefined ;
95
- }
96
-
97
- export const isInqCompareOp = < V > ( op : ExtendedCompareOp )
98
- : op is InqCompareOp < V > => {
99
- return Array . isArray ( ( op as InqCompareOp < V > ) . inq ) ;
100
- }
101
-
102
- export const isNinCompareOp = < V > ( op : ExtendedCompareOp )
103
- : op is NinCompareOp < V > => {
104
- return Array . isArray ( ( op as NinCompareOp < V > ) . nin ) ;
105
- }
50
+ }
51
+
52
+ export const isBetweenCompareOp = ( op : ExtendedCompareOp < any , any , any > )
53
+ : op is BetweenCompareOp < any , any > => {
54
+ return Array . isArray ( ( op as BetweenCompareOp < any , any > ) . between ) ;
55
+ }
56
+
57
+ export const isGtCompareOp = ( op : ExtendedCompareOp < any , any , any > )
58
+ : op is GtCompareOp < any , any > => {
59
+ return ( op as GtCompareOp < any , any > ) . gt !== undefined ;
60
+ }
61
+
62
+ export const isGteCompareOp = ( op : ExtendedCompareOp < any , any , any > )
63
+ : op is GteCompareOp < any , any > => {
64
+ return ( op as GteCompareOp < any , any > ) . gte !== undefined ;
65
+ }
66
+
67
+ export const isLteCompareOp = ( op : ExtendedCompareOp < any , any , any > )
68
+ : op is LteCompareOp < any , any > => {
69
+ return ( op as LteCompareOp < any , any > ) . lte !== undefined ;
70
+ }
71
+
72
+ export const isLtCompareOp = ( op : ExtendedCompareOp < any , any , any > )
73
+ : op is LtCompareOp < any , any > => {
74
+ return ( op as LtCompareOp < any , any > ) . lt !== undefined ;
75
+ }
76
+
77
+ export const isRegexCompareOp = ( op : ExtendedCompareOp < any , any , any > )
78
+ : op is RegexCompareOp < any , any > => {
79
+ return ( op as RegexCompareOp < any , any > ) . regexp !== undefined ;
80
+ }
81
+
82
+ export const isRegexiCompareOp = ( op : ExtendedCompareOp < any , any , any > )
83
+ : op is RegexiCompareOp < any , any > => {
84
+ return ( op as RegexiCompareOp < any , any > ) . regexpi !== undefined ;
85
+ }
86
+
87
+ export const isEqualCompareOp = ( op : ExtendedCompareOp < any , any , any > )
88
+ : op is EqualCompareOp < any , any , any > => {
89
+ return ( op as EqualCompareOp < any , any , any > ) . eq !== undefined ;
90
+ }
91
+
92
+ export const isNotEqualCompareOp = ( op : ExtendedCompareOp < any , any , any > )
93
+ : op is NotEqualCompareOp < any , any , any > => {
94
+ return ( op as NotEqualCompareOp < any , any , any > ) . neq !== undefined ;
95
+ }
96
+
97
+ export const isInqCompareOp = ( op : ExtendedCompareOp < any , any , any > )
98
+ : op is InqCompareOp < any , any , any > => {
99
+ return Array . isArray ( ( op as InqCompareOp < any , any , any > ) . inq ) ;
100
+ }
101
+
102
+ export const isNinCompareOp = ( op : ExtendedCompareOp < any , any , any > )
103
+ : op is NinCompareOp < any , any , any > => {
104
+ return Array . isArray ( ( op as NinCompareOp < any , any , any > ) . nin ) ;
105
+ }
0 commit comments