dev.ts 977 B

1234567891011121314151617181920212223242526272829303132333435
  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. const a = {x: 'abc'};
  8. function foo (b, c) {
  9. return a;
  10. function bar () {
  11. var a = 0;
  12. return a;
  13. }
  14. }
  15. `,
  16. {
  17. ...NO_ADDITIONAL_NODES_PRESET,
  18. compact: false,
  19. // identifierNamesGenerator: 'dictionary',
  20. // identifiersDictionary: ['a', 'b', 'c', 'd', 'e'],
  21. identifierNamesGenerator: 'mangled',
  22. transformObjectKeys: true,
  23. stringArray: true,
  24. stringArrayThreshold: 1
  25. }
  26. ).getObfuscatedCode();
  27. console.log(obfuscatedCode);
  28. console.log(eval(obfuscatedCode));
  29. })();