dev.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. function test1 (a, b) {
  12. const baz = 'ccc';
  13. function test2 (a, b) {
  14. const bark = 'ddd';
  15. return bark;
  16. }
  17. return baz + test2();
  18. }
  19. return bar + test1();
  20. }
  21. function test3 (a, b) {
  22. const hawk = 'eee';
  23. return hawk;
  24. }
  25. foo + test() + test3();
  26. `,
  27. {
  28. ...NO_ADDITIONAL_NODES_PRESET,
  29. compact: false,
  30. identifierNamesGenerator: IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
  31. renameGlobals: true,
  32. stringArray: true,
  33. stringArrayThreshold: 1,
  34. stringArrayWrappersChainedCalls: true,
  35. stringArrayWrappersCount: 1
  36. }
  37. ).getObfuscatedCode();
  38. console.log(obfuscatedCode);
  39. console.log(eval(obfuscatedCode));
  40. })();