<commit_before># JavaScript obfuscator for Node.js

JavaScript obfuscator for Node.js is a free alternative to [js-obfuscator](https://github.com/caiguanhao/js-obfuscator) (which uses [javascriptobfuscator.com](https://javascriptobfuscator.com/Javascript-Obfuscator.aspx))

* without any limits and sending data to a server;
* compatible with ES6;
* tested on Angular2 bundle;

https://gist.github.com/sanex3339/ffc2876123b52e6d11ce45369fd53acf

## Installation

Install the package from NPM and add it to your `devDependencies`:

```sh
$ npm install --save-dev javascript-obfuscator
```

## Usage

Here's an example of how to use it:

```javascript
var JavaScriptObfuscator = require('javascript-obfuscator');

var obfuscatedCode = JavaScriptObfuscator.obfuscate(
    `
    (function(){
        var variable = 'abc';
        console.log(variable);
    })();
    `,
    {
        rotateUnicodeArray: false
    }
);

console.log(obfuscatedCode);
/*
var _0xabf1 = [
    '\x61\x62\x63', 
    '\x6c\x6f\x67'
];
(function() {
    var _0xe6fab6 = _0xabf1[0x0];
    console[_0xabf1[0x1]](_0xe6fab6);
}());
*/
```

## `obfuscate(sourceCode, options)`

This is the main function that runs the Obfuscator. 

#### `sourceCode`
Type: `string` Default: `null`

Any valid source code.

#### `options`
Type: `Object` Default: `null`

Options for the JavaScript obfuscator:

```javascript
{
    rotateUnicodeArray: true
    // ...
}
```

### Available options
#### `compact`
Type: `boolean` Default: `true`

Compact code output on one line.

#### `debugProtection`
Type: `boolean` Default: `false`

##### :warning: Can freeze browser while Developer Tools are enabled! Use at own risk.

Force enable debug mode on page load if Developer Tools panel is enabled (in some, mainly WebKit-based, browsers). This makes it almost impossible to use the Console (the debug panel).

* WebKit-based: blocks the site window, but you still can navigate through Developer Tools panel.
* Firefox: does *not* block the site window, but still won't let you use DevTools.

#### `debugProtectionInterval`
Type: `boolean` Default: `false`
<commit_msg>readme improvements<commit_after># JavaScript obfuscator for Node.js

JavaScript obfuscator for Node.js is a free alternative to [js-obfuscator](https://github.com/caiguanhao/js-obfuscator) (which uses [javascriptobfuscator.com](https://javascriptobfuscator.com/Javascript-Obfuscator.aspx))

* without any limits and sending data to a server;
* compatible with ES6;
* tested on Angular2 bundle;

https://gist.github.com/sanex3339/ffc2876123b52e6d11ce45369fd53acf

## Installation

Install the package from NPM and add it to your `devDependencies`:

```sh
$ npm install --save-dev javascript-obfuscator
```

## Usage

Here's an example of how to use it:

```javascript
var JavaScriptObfuscator = require('javascript-obfuscator');

var obfuscatedCode = JavaScriptObfuscator.obfuscate(
    `
    (function(){
        var variable = 'abc';
        console.log(variable);
    })();
    `,
    {
        rotateUnicodeArray: false
    }
);

console.log(obfuscatedCode);
/*
var _0xabf1 = [
    '\x61\x62\x63', 
    '\x6c\x6f\x67'
];
(function() {
    var _0xe6fab6 = _0xabf1[0x0];
    console[_0xabf1[0x1]](_0xe6fab6);
}());
*/
```

## `obfuscate(sourceCode, options)`

This is the main function that runs the Obfuscator. It takes two parameters, `sourceCode` and `options` – the source code and the opitons respectively:

* `sourceCode` (`string`, default: `null`) – any valid source code, passed as a string variable. JS Obfuscator will parse this string and apply a set of modificating functions to it, generating a string with the new (obfuscated) code and printing it to the console;
* `options` (`Object`, default: `null`) – an object literal.

## JavaScript Obfuscator Options

At this moment of time, there are following options (`name: default`) available for the JS Obfuscator:

```javascript
{
    compact: true,
    debugProtection: false,
    debugProtectionInterval: false,
    disableConsoleOutput: true,
    encodeUnicodeLiterals: false,
    reservedNames: [],
    rotateUnicodeArray: true,
    selfDefending: true,
    unicodeArray: true,
    unicodeArrayThreshold: 0.8,
    wrapUnicodeArrayCalls: true
}
```

* `compact` (default `true`): output code on one line,
* `debugProtection` (default `false`): force load debug mode 
* `debugProtectionInterval` (default `false`):
* `disableConsoleOutput` (default `true`):
* `encodeUnicodeLiterals` (default `false`):
* `reservedNames` (default `[]`):
* `rotateUnicodeArray` (default `true`):
* `selfDefending` (default `true`):
* `unicodeArray` (default `true`):
* `unicodeArrayThreshold` (default `0.8`):
* `wrapUnicodeArrayCalls` (default `true`):


#### `compact`
Type: `boolean` Default: `true`

Compact code output on one line.

#### `debugProtection`
Type: `boolean` Default: `false`

##### :warning: Can freeze browser while Developer Tools are enabled! Use at own risk.

Force enable debug mode on page load if Developer Tools panel is enabled (in some, mainly WebKit-based, browsers). This makes it almost impossible to use the Console (the debug panel).

* WebKit-based: blocks the site window, but you still can navigate through Developer Tools panel.
* Firefox: does *not* block the site window, but still won't let you use DevTools.

#### `debugProtectionInterval`
Type: `boolean` Default: `false`

{'fraction_non_alphanumeric': 0.12304832713754647, 'fraction_numerical': 0.01970260223048327, 'mean_word_length': 4.490816326530612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7672486', 'n_tokens_mistral': 1805, 'n_tokens_neox': 1708, 'n_words': 549}