UNPKG

vanzy-protect

Version:

Epic Obfuscator Yeahhh

51 lines (50 loc) 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.drawFunction = void 0; const cfg_1 = require("../config/cfg"); const warn_1 = require("../log/warn"); const comment_1 = require("../obfuscate/comment"); const obfuscateName_1 = require("../obfuscate/obfuscateName"); const arrayPattern_1 = require("./arrayPattern"); const assignmentExpression_1 = require("./assignmentExpression"); const objectPattern_1 = require("./objectPattern"); const traverse_1 = require("./traverse"); function drawFunction(fnblock, data = '') { if (fnblock.async) { data += 'async'; data += ' '; data += (0, comment_1.comment)(1); } data += 'function '; data += (0, comment_1.comment)(1); var name = fnblock.id.name; if ((0, cfg_1.cfg)().transforms.obfuscateNames) name = (0, obfuscateName_1.obfuscateName)(name); data += name; data += (0, comment_1.comment)(2); data += '('; fnblock.params.forEach((i, n) => { if (i.type === 'Identifier') { var pname = i.name; if ((0, cfg_1.cfg)().transforms.obfuscateNames) pname = (0, obfuscateName_1.obfuscateName)(pname); data += pname + (0, comment_1.comment)(3) + ',' + (0, comment_1.comment)(3); } else if (i.type === 'AssignmentPattern') { data += (0, assignmentExpression_1.assignmentExpression)({ operator: '=', ...i }) + (0, comment_1.comment)(3) + ',' + (0, comment_1.comment)(3); } else if (i.type === 'ObjectPattern') { data += (0, objectPattern_1.objectPattern)(i) + (0, comment_1.comment)(3) + ',' + (0, comment_1.comment)(3); } else if (i.type === 'ArrayPattern') { data += (0, arrayPattern_1.arrayPattern)(i) + (0, comment_1.comment)(3) + ',' + (0, comment_1.comment)(3); } else (0, warn_1.warn)(`Unknown expression type in methodDefinition(e) => e.params[${n}] : ${i.type}`); }); data += ')' + (0, comment_1.comment)(2) + '{'; data += (0, traverse_1.traverse)(fnblock.body.body); data += (0, comment_1.comment)(3) + '}' + (0, comment_1.comment)(1); return data; } exports.drawFunction = drawFunction;