Transpiler ES5 to ES6

by bgoonz

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">var CarFn = (function () {
    var id = 0;
	return function() {
		return {
			id: ++id
        };
    };
})();</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());
}