When you need to use a transformation with custom options you can define
an alias, and reuse it when needed.
/**
* @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.
/**
* @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.
// @jscrambler define selfDefending {threshold: 512} as sd1
function foo () {
function bar () {
// @jscrambler enable sd1
function baz () {}
function qux () {}
// @jscrambler enable sd1
function quux () {}
}
}
The alias sd1
is attached to the function foo
and any of its children but it is only enabled in the function baz
and quux
.