vanzy-protect
Version:
Epic Obfuscator Yeahhh
54 lines (53 loc) • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.traverse = void 0;
const doWhileStatement_1 = require("./doWhileStatement");
const drawClass_1 = require("./drawClass");
const drawFunction_1 = require("./drawFunction");
const expressionStatement_1 = require("./expressionStatement");
const fancyForStatement_1 = require("./fancyForStatement");
const forStatement_1 = require("./forStatement");
const ifStatement_1 = require("./ifStatement");
const returnStatement_1 = require("./returnStatement");
const variableDeclaration_1 = require("./variableDeclaration");
const whileStatement_1 = require("./whileStatement");
function traverse(ast, data = '') {
var shouldAddComma = false;
ast.forEach((i, n) => {
if (i.type === 'FunctionDeclaration') {
data += (0, drawFunction_1.drawFunction)(i);
}
else if (i.type === 'ExpressionStatement') {
data += (0, expressionStatement_1.expressionStatement)(i);
shouldAddComma = ast[n + 1]?.type === 'ExpressionStatement';
}
else if (i.type === 'VariableDeclaration') {
data += (0, variableDeclaration_1.variableDeclaration)(i);
}
else if (i.type === 'ReturnStatement') {
data += (0, returnStatement_1.returnStatement)(i);
}
else if (i.type === 'IfStatement') {
data += (0, ifStatement_1.ifStatement)(i);
}
else if (i.type === 'WhileStatement') {
data += (0, whileStatement_1.whileStatement)(i);
}
else if (i.type === 'DoWhileStatement') {
data += (0, doWhileStatement_1.doWhileStatement)(i);
}
else if (i.type === 'ForStatement') {
data += (0, forStatement_1.forStatement)(i);
}
else if (i.type === 'ForInStatement' || i.type === 'ForOfStatement') {
data += (0, fancyForStatement_1.fancyForStatement)(i);
}
else if (i.type === 'ClassDeclaration') {
data += (0, drawClass_1.drawClass)(i);
}
data += shouldAddComma ? ',' : ';\n';
shouldAddComma = false;
});
return data;
}
exports.traverse = traverse;