File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1
1
import alwaysFk from './transforms/alwaysFk.js' ;
2
+ import poggers from './transforms/poggers.js' ;
2
3
import { parseScript } from 'meriyah' ;
3
4
import { walk } from 'estree-walker' ;
4
5
import { generate } from 'astring' ;
@@ -14,6 +15,7 @@ export default function transform(source) {
14
15
walk ( ast , {
15
16
enter ( node ) {
16
17
alwaysFk ( node , this ) ;
18
+ poggers ( node , this ) ;
17
19
}
18
20
} ) ;
19
21
console . timeEnd ( 'walking' ) ;
Original file line number Diff line number Diff line change
1
+ export default function poggers ( node , ctx ) {
2
+ if ( node . type !== 'ConditionalExpression' ) return ;
3
+
4
+ if ( node . test . type === 'BinaryExpression' ) {
5
+ if ( node . consequent . type !== 'Literal' ) return ;
6
+ if ( node . consequent . value !== 'MAJOR' ) return ;
7
+
8
+ ctx . replace ( {
9
+ type : 'ConditionalExpression' ,
10
+ test : {
11
+ type : 'BinaryExpression' ,
12
+ operator : '>=' ,
13
+ left : node . test . left ,
14
+ right : {
15
+ type : 'Literal' ,
16
+ value : 1.0 ,
17
+ }
18
+ } ,
19
+ consequent : {
20
+ type : 'Literal' ,
21
+ value : 'POGGERS' ,
22
+ } ,
23
+ alternate : node ,
24
+ } ) ;
25
+ ctx . skip ( ) ;
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments