decaffeinate-parser

2018-12-07 admin

decaffeinate-parser是什么

什么是decaffeinate-parser,A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

decaffeinate-parser使用教程帮助文档

decaffeinate-parser Build Status package version Greenkeeper badge

This project uses the official CoffeeScript parser to parse CoffeeScript source code, then maps the AST generated by the parser to one more suitable for the decaffeinate project (based on the AST generated by CoffeeScriptRedux).

This project might be useful to anyone who wants to work with a CoffeeScript AST and prefers working with a saner AST.

Install

# via yarn
$ yarn add decaffeinate-parser
# via npm
$ npm install decaffeinate-parser

Usage

This example gets the names of the parameters in the add function:

import { parse } from 'decaffeinate-parser';

let program = parse('add = (a, b) -> a + b');
let assignment = program.body.statements[0];
let fn = assignment.expression;

console.log(fn.parameters.map(param => param.data)); // [ 'a', 'b' ]

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-47528.html

文章标题:decaffeinate-parser

回到顶部