xto6
v1.1.1-alpha es5 es6 transpiler transpile
xto6
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.
Why?
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;
}
Usage
Install it using npm :
$ npm install -g xto6
Transpile your old-fashioned code using the xto6
cli tool.
xto6 es5.js -o es6.js
And 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;
}
Want to convert your whole project to ES6 syntax for even greater awesomeness? No problem!
$ find . -type f -not -path "*node_modules*" -name "*.js" -print0 | xargs -0 -I % xto6 % -o %
Supported Features
- Function/Prototypes to Classes
- Callback to Arrow functions
- String concatenation to Template Strings
- Using
let
andconst
instead ofvar
- Default arguments instead of
a = a || 2
- Function properties in objects to Object methods
npm i [email protected]
Metadata
- MIT
- >=0.12
- Mohamad Mohebifar
- released 5/2/2015