dev.ts 909 B

1234567891011121314151617181920212223242526272829
  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 test';
  9. function test () {
  10. const bar = 'bar';
  11. }
  12. `,
  13. {
  14. ...NO_ADDITIONAL_NODES_PRESET,
  15. compact: false,
  16. identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
  17. stringArray: true,
  18. stringArrayThreshold: 1,
  19. unicodeEscapeSequence: false
  20. }
  21. ).getObfuscatedCode();
  22. console.log(obfuscatedCode);
  23. console.log(eval(obfuscatedCode));
  24. })();