decaffeinate-parser
TypeScript icon, indicating that this package has built-in type declarations

23.0.1 • Public • Published

decaffeinate-parser CI package version

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';

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

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

Readme

Keywords

Package Sidebar

Install

npm i decaffeinate-parser

Weekly Downloads

11,280

Version

23.0.1

License

MIT

Unpacked Size

287 kB

Total Files

6

Last publish

Collaborators

  • eventualbuddha
  • decaffeinate-bot