js2coffee-redux
Compile JavaScript into CoffeeScript.
Last updated 6 years ago by rstacruz .
MIT · Original npm · Tarball · package.json
$ cnpm install js2coffee-redux 
SYNC missed versions from official npm registry.

Compile JavaScript into CoffeeScript.

Status

This 2.0 release is a complete rewrite featuring a better parser (Esprima). See the migration guide for instructions on how to update from 0.x.


Install

Available on npm and bower.

npm install --global js2coffee
js2coffee --help

npm version

Also available via CDN (window.js2coffee):

http://cdn.rawgit.com/js2coffee/js2coffee-redux/v0.0.17/dist/js2coffee.js


Command line

The command line utility accepts both filenames or stdin.

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

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.

  • Goals - outline of the project's goals.

  • Specs - examples of how JavaScript compiles to CoffeeScript.

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

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


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:

Current Tags

  • 0.0.17                                ...           latest (6 years ago)

16 Versions

  • 0.0.17                                ...           6 years ago
  • 0.0.16                                ...           6 years ago
  • 0.0.15                                ...           6 years ago
  • 0.0.14                                ...           6 years ago
  • 0.0.13                                ...           6 years ago
  • 0.0.12                                ...           6 years ago
  • 0.0.11                                ...           6 years ago
  • 0.0.10                                ...           6 years ago
  • 0.0.9                                ...           6 years ago
  • 0.0.8                                ...           6 years ago
  • 0.0.7                                ...           6 years ago
  • 0.0.6                                ...           6 years ago
  • 0.0.5                                ...           6 years ago
  • 0.0.4                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (11)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |