Server IP : 162.213.251.212 / Your IP : 18.216.141.244 [ Web Server : LiteSpeed System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : allssztx ( 535) PHP Version : 8.1.31 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/home/allssztx/public_html/easybuyer/node_modules/recast/example/ |
Upload File : |
#!/usr/bin/env node var recast = require("recast"); var types = recast.types; var n = types.namedTypes; var b = types.builders; require("recast").run(function(ast, callback) { recast.visit(ast, { visitIfStatement: function(path) { var stmt = path.node; stmt.consequent = fix(stmt.consequent); var alt = stmt.alternate; if (!n.IfStatement.check(alt)) { stmt.alternate = fix(alt); } this.traverse(path); }, visitWhileStatement: visitLoop, visitForStatement: visitLoop, visitForInStatement: visitLoop }); callback(ast); }); function visitLoop(path) { var loop = path.node; loop.body = fix(loop.body); this.traverse(path); } function fix(clause) { if (clause) { if (!n.BlockStatement.check(clause)) { clause = b.blockStatement([clause]); } } return clause; }