distinctiomagnam
Version:
JavaScript Obfuscation Tool.
32 lines (24 loc) • 772 B
text/typescript
import { ok } from "assert";
import { writeFileSync } from "fs";
import { ObfuscateOptions } from "./options";
import { Node } from "./util/gen";
const escodegen = require("escodegen");
export default async function compileJs(tree: any, options: ObfuscateOptions) {
return compileJsSync(tree, options);
}
export function compileJsSync(tree: any, options: ObfuscateOptions): string {
var api: any = { format: escodegen.FORMAT_MINIFY };
if (!options.compact) {
api = {};
if (options.indent && options.indent != 4) {
api.format = {};
api.format.indent = {
style: { 2: " ", tabs: "\t" }[options.indent] || " ",
};
}
}
if (options.debugComments) {
api.comment = true;
}
return escodegen.generate(tree, api);
}