Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decaffeinate-parser

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decaffeinate-parser

A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-64.21%
Maintainers
1
Weekly downloads
 
Created
Source

decaffeinate-parser

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 the AST generated by CoffeeScriptRedux, but wants to avoid the source compatibility issues introduced by using that project. Note that it is not 100% compatible with CoffeeScriptRedux:

  • Single-line functions, if statements, etc. have blocks for bodies.
  • String interpolation nodes are modeled after TemplateLiteral from ES6 rather than being a series of nested ConcatOp nodes.
  • Triple-quoted strings have the node type Herestring rather than String.
  • Virtual nodes (such as the LogicalNotOp generated by an unless) are marked as such with a virtual: true property.
  • do is handled with the DoOp node type.
  • for-in loops do not have an implicit step property.
  • Ranges of programs with indented blocks are correct.
  • super is supported in classes.
  • extends is usable as a binary operator and in class declarations.
  • // (floor division) is supported.

Install

$ npm install --save-dev 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' ]

Keywords

FAQs

Package last updated on 24 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc