Fork me on GitHub

Extend.js


This page is no longer maintained, please check out our GitHub repo or NPM package for an updated version of the CLI.

Source code

Compiled

The actual rules behind it

Try modifying/creating your own!

How it works

Each rule consists of two parts: template and output.
template is what the transpiler is looking for, it describes what your rule looks like. here is an example:

{array} [{index}]

Here we have declared two variables array and index, using the synyax {variableName}. to put these variables into action you will need the second part of the rule, the output.

function({array, index}){ if(index>0){ return `${array}[${i}]` } return `${array}[${array}.length-${i}]` }

The output is a normal javascript function that recieves an object containing all variables that the transpiler found, it can be a good idea to use destructuring here.

The return of this function is what the compiler is going write to your code. if for any reason you think that something went wrong and you don't want to process this code, ie: one variable is undefined or it's conflicting with a different rule, just return false.

One last thing you need to know is the escape character which is the # sign.