xto6 transpiles your ES5 code to ES6. It does exactly the opposite of what other transpilers do (like babel and traceur)! If you want to understand what xto6 exactly does, try the live demo.
Still coding this way ? Think twice !
var SomeClass = function () {
console.log('This is the constructor.');
};
SomeClass.prototype.someOuterMethod = someFunction;
SomeClass.prototype.someInnerMethod = function (birthYear) {
var result = 'Your Age is : ' + (2015 - birthYear) + ' and you were born in ' + birthYear;
return result;
};
Object.defineProperty(SomeClass.prototype, 'someAccessor', {
get: function () {
return this._some;
},
set: function (value) {
this._some = value;
}
});
function someFunction(a, b) {
return a + b;
}Install it using npm :
$ npm install -g xto6Transpile your old-fashioned code using the xto6 cli tool.
xto6 es5.js -o es6.jsAnd the result for the code above is :
class SomeClass {
constructor() {
console.log('This is the constructor.');
}
someOuterMethod() {
return someFunction.apply(this, arguments);
}
someInnerMethod(birthYear) {
var result = `Your Age is : ${ 2015 - birthYear } and you were born in ${ birthYear }`;
return result;
}
get someAccessor() {
return this._some;
}
set someAccessor(value) {
this._some = value;
}
}
function someFunction(a, b) {
return a + b;
}- Function/Prototypes to Classes
- Callback to Arrow functions
- String concatenation to Template Strings
- Using
letandconstinstead ofvar - Default arguments instead of
a = a || 2 - Function properties in objects to Object methods