dev.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNodes';
  3. import { IdentifierNamesGenerator } from '../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
  4. (function () {
  5. const JavaScriptObfuscator: any = require('../../index');
  6. let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
  7. `
  8. const foo = 'aaa';
  9. function test (a, b) {
  10. const bar = 'bbb';
  11. return a + b;
  12. }
  13. function test1 (a, b) {
  14. const bar = 'bbb';
  15. return a + b;
  16. }
  17. test();
  18. var baz = 5;
  19. `,
  20. {
  21. ...NO_ADDITIONAL_NODES_PRESET,
  22. compact: false,
  23. identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
  24. renameGlobals: true,
  25. stringArray: true,
  26. stringArrayThreshold: 1,
  27. stringArrayWrappersChainedCalls: true,
  28. stringArrayWrappersCount: 1
  29. }
  30. ).getObfuscatedCode();
  31. console.log(obfuscatedCode);
  32. console.log(eval(obfuscatedCode));
  33. })();