dev.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNodes';
  3. (function () {
  4. const JavaScriptObfuscator: any = require('../../index');
  5. let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
  6. `
  7. (function () {
  8. function foo () {
  9. const f = {f: 1};
  10. const g = {g: 2};
  11. const h = {h: 3};
  12. const i = {i: 4};
  13. const j = {j: 5};
  14. }
  15. function bar () {
  16. const a = 11;
  17. const b = 12;
  18. const c = 13;
  19. const d = 14;
  20. const e = 15;
  21. }
  22. })();
  23. `,
  24. {
  25. ...NO_ADDITIONAL_NODES_PRESET,
  26. compact: false,
  27. deadCodeInjection: true,
  28. deadCodeInjectionThreshold: 1,
  29. identifierNamesGenerator: 'mangled',
  30. log: true,
  31. transformObjectKeys: true
  32. }
  33. ).getObfuscatedCode();
  34. console.log(obfuscatedCode);
  35. console.log(eval(obfuscatedCode));
  36. })();