We will be at OWASP APPSEC EUROPE 2017 - Belfast! Let’s talk!MORE INFO

Help Center

Get to know more about our API, Code Annotations and Code Transformations

Define

When you need to use a transformation with custom options you can define an alias, and reuse it when needed.

1
2
3
4
5
/**
* @jscrambler define selfDefending {threshold: 512} as sd1
* @jscrambler enable sd1
*/
function foo () {}

In this example, self-defending capabilities are added to the function foo only when the size of the function is at least 512 chars long.

You can also define global aliases when you need to use the alias globally.

1
2
3
4
5
6
7
/**
* @jscrambler global define selfDefending {threshold: 512} as sd1
* @jscrambler global enable sd1
*/
function foo () {}
function bar () {}
function baz () {}

Aliases are also inherited from upper blocks so if you define an alias for a block you can enable it not only in that block but also in any of the inner statements and blocks.

1
2
3
4
5
6
7
// @jscrambler define selfDefending {threshold: 512} as sd1
function foo () {
function bar () {
// @jscrambler enable sd1
function baz () {}
}
}

The alias sd1 is attached to the function foo and any of its children but it is only used in the function baz.