• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

js2coffee/js2coffee: Compile JavaScript to CoffeeScript

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

js2coffee/js2coffee

开源软件地址:

https://github.com/js2coffee/js2coffee

开源编程语言:

CoffeeScript 94.6%

开源软件介绍:

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:




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap