UNPKG

vanzy-protect

Version:

Epic Obfuscator Yeahhh

39 lines (38 loc) 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.objectExpression = void 0; const cfg_1 = require("../config/cfg"); const warn_1 = require("../log/warn"); const comment_1 = require("../obfuscate/comment"); const stringObf_1 = require("../obfuscate/stringObf"); const rightExpression_1 = require("./rightExpression"); function objectExpression(expr) { var data = (0, comment_1.comment)(2) + '{'; expr.properties.forEach((i, n) => { if (i.computed) { (0, warn_1.warn)(`Computed property in objectExpression: ${JSON.stringify(i)}`); } else { if (i.type === 'Property') { data += '['; if (i.key.type === 'Identifier') { data += (0, stringObf_1.stringObf)(i.key.name, (0, cfg_1.cfg)().transforms.keyObfuscationLevel); } else { data += (0, rightExpression_1.rightExpression)(i.key); } data += (0, comment_1.comment)(3) + ']:' + (0, rightExpression_1.rightExpression)(i.value); } else if (i.type === 'SpreadElement') { data += '...' + (0, comment_1.comment)(3) + (0, rightExpression_1.rightExpression)(i.argument); } else (0, warn_1.warn)(`Unknown expression type in objectExpression(e) => e.properties[${n}] : ${i.type}`); } data += (0, comment_1.comment)(2); data += ','; }); data += '}' + (0, comment_1.comment)(3); return data; } exports.objectExpression = objectExpression;