const fs = require('fs'); const {parse} = require("@babel/parser"); const traverse = require("@babel/traverse").default; const t = require("@babel/types"); const generator = require("@babel/generator").default; let jscode = `var s=92;b=Z(1324801,s); `; let ast = parse(jscode); const visitor = { "Identifier"(path) { const {confident,value} = path.evaluate(); console.log(confident,value); confident && path.replaceInline(t.valueToNode(value)); }, } traverse(ast, visitor); let {code} = generator(ast); console.log(code); //----------------------------------
var s = 92;
b = Z(1324801, 92);