dev.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 = 'foo'
  9. const bar = 'bar';
  10. const baz = 'baz';
  11. function test (arg = 'bark') {
  12. const hawk = 'hawk';
  13. const eagle = 'eagle';
  14. console.log(arg, hawk, eagle);
  15. }
  16. test();
  17. `,
  18. {
  19. ...NO_ADDITIONAL_NODES_PRESET,
  20. compact: false,
  21. identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
  22. renameGlobals: true,
  23. stringArray: true,
  24. transformObjectKeys: true,
  25. stringArrayThreshold: 1,
  26. stringArrayWrappersChainedCalls: false,
  27. stringArrayWrappersCount: 2
  28. }
  29. ).getObfuscatedCode();
  30. console.log(obfuscatedCode);
  31. console.log(eval(obfuscatedCode));
  32. })();