Transpiler ES5 to ES6
by josekerekes
HTML
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://rawgit.com/hugeen/lebab-experiment/master/lebab.js"></script>
<textarea id="source">[1, 2, 3].map(function(n) { return n * 2; }, this);</textarea>
<button id="transpile">Transpile 5to6</button>
<pre id="destination"></pre>
CSS
textarea {
display: block;
width: 100%;
min-height: 5rem;
}
pre {
background: white;
padding: 10px;
}
JavaScript
var transformer = new Lebab.Transformer();
var source = $('#source');
var destination = $('#destination');
$('#transpile').on('click', function () {
transpile(source.val())
});
function transpile(code) {
transformer.read(code);
transformer.applyTransformations();
destination.html(transformer.out());
}