5 ms·
Turn your ES5 code into readable ES6
- untog 12y agoInteresting idea, but the backwards compatibility of ES6 means that you can refactor a project piece by piece as you work on it - IMO that's a better approach.
- TazeTSchnitzel 12y agoHmm. How smart is it? Can it detect when some usage of prototypes is not class-like and not convert it to an ES6 class?
- mohebifar 12y agoIn case you said, it can discern non-class-like function as nothing is assigned to its prototype. Bu on the whole I cannot really tell you how smart it is because it is in alpha stage. We need more users to test it.
- bphogan 12y agoI think this is awesome just for the sake of doing it. I'm always impressed with how these kinds of projects are implemented.
- patrickaljord 12y agoThere's also this one https://github.com/mping/5to6 https://github.com/mping/5to6
- mohebifar 12y agoYes, And it's 3 days younger than xto6. It does not support function/prototype => classes. And also it is trying to encourage people to convert their ES5 codes into ES6 but it's implemented in ES5 itself !
- deleted 12y ago[deleted]
- icebraining 12y agoDon't take it as an attack, it's always better to have more choices and approaches to learn from, nobody is trying to diminish your work.
- mohebifar 12y agoSorry, You're right.
- deleted 12y ago[deleted]
- luca_barbieri 12y agoI have started a similar project, but stopped working on it, and seeing this I decided to put it on GitHub, even though it's not very well tested and not feature complete. The most complex feature in my code is the ability to turn var into let/const optimally using an esgraph-based dataflow analysis, and it also has the ability to introduce arrow functions, shorthand/method properties and classes. It is implemented as a fork of Babel with slightly changed packaging and a bunch of ES5-to-ES6 passes. I'm not sure if I'm going to do any further work on this, so feel free to incorporate the code into your project if you find it useful or start maintaining a fork. It has been tested a bit but as much as it should, so it may not just work out of the box. You can find it at https://github.com/luca-barbieri/5to6 https://github.com/luca-barbieri/5to6
- mohebifar 12y agoThat's great! It's kind of you. I will use that.
- tlrobinson 12y agoNeat. How about translating "require" calls to "import" statements (and exports statements)?
- skrebbel 12y agoi did that yesterday by hand with 3 find-replace-all regexes. it isn't that big a deal :-) (that said, not all uses of require can be translated to import statements)
- itsbits 12y agogood idea..what all features currently you are converting to ES6? Better list them in github...
- pascalo 12y agoSadly I get an error "Cannot find module './block-statement.js"
- mohebifar 12y agoI fixed it
- dzhiurgis 12y agoI am asking as a poor JS developer - what are the benefits of this newer style?
- nodesocket 12y agoReadable, and intuitive. The syntax is like a standard class (constructor, methods, getters, setters) you'd see in C or PHP.
- yoklov 12y agoC++, you mean. There are no classes in C.
- dzhiurgis 12y agoWhat is the benefit of using classes rather than just bunch of functions, calling each other?
- ajanuary 12y agoThere are strong arguments for both, but if you're going to decide on classes, ES6 classes are preferable to ES5 style.
- nextweek2 12y agoThat's a big question, its usually a first year software engineering degree assignment. Its the question of object orientated programming vs procedural programming. The main thing with having classes is about encapsulating functionality into objects which can be tested, reused and extended as a component in its own right.
- rhizome31 12y agoOften when you use a bunch of functions together, you end up passing the same arguments. Those arguments represent some kind of state that your pass around from functions to functions. Sometimes you might even add an argument to a function just to pass it over to another function. After a while you might get tired of changing your function signatures and it makes sense to group those common arguments into a single data structure that can be accessed by your bunch of functions working together. While you're at it you might as well put the functions in that data structure too, so you can see clearly how they relate to each other. That's basically what a class is for.
- emehrkay 12y agoES6 will be nice when I can write it without the worry of a compilation stage. I still use MooTools on my personal projects. I don't care. I get shit done.
- afshinmeh 12y agoupvoted. Damet garm amoo :D
- mohebifar 12y agoThank you. Kharabetam :D