dev.ts 983 B

123456789101112131415161718192021222324252627282930313233343536
  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. var x = {
  8. baz_: 0,
  9. foo_: 1,
  10. calc: function() {
  11. return this.foo_ + this.baz_;
  12. }
  13. };
  14. x.bar_ = 2;
  15. x["baz_"] = 3;
  16. console.log(x.calc());
  17. `,
  18. {
  19. ...NO_ADDITIONAL_NODES_PRESET,
  20. compact: false,
  21. log: true,
  22. identifierNamesGenerator: 'mangled',
  23. renameGlobals: true,
  24. splitStrings: true,
  25. splitStringsChunkLength: 3,
  26. stringArray: true,
  27. stringArrayThreshold: 1
  28. }
  29. ).getObfuscatedCode();
  30. console.log(obfuscatedCode);
  31. console.log(eval(obfuscatedCode));
  32. })();