Giter Club home page Giter Club logo

decaf's Introduction

Decaf JS

Build Status

A coffeescript to ES.next transpiler Try it out online

Decaf grew out of the frustration of having to refactor coffeescript to modern JavaScript syntax. It does that for you automatically.

Because decaf uses the coffeescript compiler under the hood it has an advantage over other coffeescript transpilers. Decaf aims to be able to compile all coffeescript, but it is still a fairly young project. Please try decaf and submit issues if you run into problems, I and a couple of amazing contributors are working hard on completing decaf.

When decaf encounters coffeescript syntax which can't be transpiled to es6 it falls back to using the coffeescript compiler output.

At the moment decaf can transpile a fairly wide range of coffeescript syntax. To get a better idea of which features are supported, please have a look at the test suite.

Using decaf as a cli tool

To use decaf as a cli tool install it first via npm.

npm install decafjs -g (you can also install it locally, but if you are using it for more projects, installing it globally is recommended)

Now simply point decaf at a file or a directory that you want to convert to es6 and tada:

decaf coffee-folder

Using decaf as a code transform

You can require decaf as a node module and simply use it as a transform. We recommend using it with tools like jscodeshift.

To install run npm install decafjs.

To use it simply require it as any other node module:

var decaf = require('decafjs');
var js = decaf.compile('()-> alert "yoyoyo"');

As a second argument, you can parse options to the javascript printer, we use recast to print the js, so any options you pass as a second argument will be passed onto it.

Todo

  • Single and multi-comment lines (can't be done with coffeescript parser, also it's very unintuitive right now to create comment blocks with the ast-types library)

Design choices

  • Coffeescript compiler to build coffeescript syntax tree.
  • Using ast-types, a library for building an esprima compatible syntax tree
  • Using jscodeshift for code optimisation (like automatically declaring undeclared variables)

decaf's People

Contributors

juliankrispel avatar goodforonefare avatar lemonmade avatar tsuchikazu avatar bouk avatar flying-sheep avatar eventualbuddha avatar karlhorky avatar

Stargazers

 avatar Daniel Bayley avatar  avatar Andy Fang avatar Juan Guerrero avatar Emiliano Qaqi avatar

Watchers

Lourens Naudé avatar Christian Zacharias avatar Jeff Bruton avatar Jamie Sutton avatar Ryan Langlois avatar Rohit Mishra avatar  avatar Caroline avatar Ben Watts avatar Ben Doyle avatar Peter Nitsch avatar tetchi avatar  avatar Dan Menard avatar Mladen Rangelov avatar  avatar Peter de Wit avatar James Cloos avatar Ivan Savytskyi avatar Andrew Louis avatar Vadym Tyemirov avatar Marcelo nakashima de brito avatar  avatar Daniel Leroux avatar Andrea Di Persio avatar Alex Fi avatar Mounir avatar Frank Reding avatar Satish Kanwar avatar Niko Kurtti avatar Sherry Shao avatar Brandon avatar Louis Kearns avatar Nicholas Simmons avatar Chris avatar Kirsten Westeinde avatar Solmaz avatar Michael Beddall avatar Sergio Roysen avatar Ian Martin avatar Will Mowat avatar Arbab Ahmed avatar Peter DeNitto avatar Pri Kuruppu avatar Nicolas Tual avatar Mallory Allen avatar Daniel Hopper avatar reggordon avatar  avatar  avatar Nathan Tappin avatar Davin Henrikson avatar  avatar Marc Posth avatar Mohammad Hashemi avatar Ayal Sadeh avatar Graham Cooper avatar Marek Galovic avatar Andrea Brabant avatar Sam Butler avatar Lawrence Callender avatar Alëna Iouguina avatar Jessica Xie avatar Jonathan Tremblay avatar  avatar Joseph Kim avatar James Woo avatar Atlee avatar Elisa Kazan avatar Alex Fattouche avatar  avatar James Welch avatar Joey Renda  avatar David Zhou avatar Fred Dawson avatar  avatar Jimmy Guo avatar Samuel Siegart avatar Josh Baker avatar  avatar  avatar  avatar  avatar Kai Luo avatar Rabeea Ahmad avatar Melissa Li avatar xeni_lols avatar Phil Kim avatar Julia S avatar  avatar Annette Keys avatar Kitty Huang avatar Sarah Langille avatar  avatar Racheal Herlihy avatar  avatar Colin avatar Irene Nam avatar Elizabeth Sahadeo avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.