GithubHelp home page GithubHelp logo

doc22940 / js2coffee Goto Github PK

View Code? Open in Web Editor NEW

This project forked from js2coffee/js2coffee

0.0 1.0 0.0 2.13 MB

Compile JavaScript to CoffeeScript

Home Page: http://js2.coffee

License: MIT License

Makefile 0.61% JavaScript 4.84% CoffeeScript 94.55%

js2coffee's Introduction

js2coffee

Compile JavaScript into CoffeeScript.

Status

This 2.0 release is a complete rewrite featuring a better parser (Esprima). See what's new in 2.0 for an overview of new features and consult the migration guide for info on updating from 0.x.


Install

Available on npm and bower.

npm install --global js2coffee
js2coffee --help

npm version

Also available via CDN (window.js2coffee):

https://cdn.rawgit.com/js2coffee/js2coffee/v2.1.0/dist/js2coffee.js


Command line

The command line utility accepts both filenames or stdin.

$ js2coffee file.js [file2.js ...]
$ cat file.js | js2coffee

JavaScript API

Available via npm (require('js2coffee')), or via CDN in the browser (as window.js2coffee):

result = js2coffee.build(source);

result.code     // code string
result.ast      // transformed AST
result.map      // source map
result.warnings // array of warnings

Errors are in this format:

catch (e) {
  e.message       // "index.js:3:1: Unexpected INDENT\n\n   3   var\n   ---^"
  e.description   // "Unexpected INDENT"
  e.start         // { line: 1, column: 4 }
  e.end           // { line: 1, column: 10 }
  e.sourcePreview // '...'
}

Warnings are in this format:

result.warnings.forEach((warn) => {
  warn.description   // "Variable 'x' defined twice
  warn.start         // { line: 1, column: 4 }
  warn.end           // { line: 1, column: 9 }
  warn.filename      // "index.js"
})

Docs

  • Migration guide - guide for migrating from 0.x.

  • Hacking guide - want to contribute? here are tips to get you started.

  • AST format - technical description of the CoffeeScript AST format.

  • Special cases - a list of edge cases that js2coffee accounts for.

  • Compatibility mode - list of tweaks that compatibility mode (--compat) addresses.

  • Goals - outline of the project's goals.

  • Specs - examples of how JavaScript compiles to CoffeeScript.


Thanks

js2coffee © 2012+, Rico Sta. Cruz. Released under the MIT License.
Authored by Rico Sta. Cruz with help from co-maintainers and contributors (list).

Maintainers:

js2coffee's People

Contributors

rstacruz avatar greenkeeperio-bot avatar rianhunter avatar ariya avatar snowyu avatar marnen avatar michaelficarra avatar

Watchers

 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.