Registry / serialization / bouk-decafjs

bouk-decafjs

JSON →
library0.1.0jsnpmunverified

Decaf JS is a CoffeeScript-to-ES.next transpiler that leverages the CoffeeScript compiler to build a syntax tree and then outputs modern JavaScript. The current stable version is 0.1.0, with infrequent releases. Its key differentiator is the ability to fall back to the CoffeeScript compiler output for unsupported syntax, aiming to cover the full CoffeeScript language. It can be used as a CLI tool or integrated as a code transform with tools like jscodeshift. It uses ast-types for building an esprima-compatible AST and recast for printing JavaScript.

npm install bouk-decafjs
INSTALL
IMPORT
SIG · BOUK-DECAFJS
B
bouk-decafjs
serializationjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

decaf
import decaf from 'decafjs'
var decaf = require('decafjs')
ESM default import or CommonJS require both work; the package is not strict ESM.
compile
decaf.compile(code, options)
The compile function is attached to the default export when using require or import.
default
const decaf = require('decafjs')
CommonJS require works; the module exports a single function/object with compile method.

Shows how to compile a simple CoffeeScript arrow function to JavaScript using decaf with recast options.

const decaf = require('decafjs'); const coffee = 'square = (x) -> x * x'; const js = decaf.compile(coffee, { tabWidth: 2 }); console.log(js);
decaf --version
Debug
Known issues
gotchaDecaf may not support all CoffeeScript syntax and falls back to CoffeeScript compiler output for unsupported patterns, which may produce ES5 instead of ES6.
fix
Check the test suite for supported features; contribute or submit issues for unsupported syntax.
affects: >=0.1.0
deprecatedThe package has seen infrequent updates and may be considered in maintenance mode.
fix
Consider alternatives like CoffeeScript's own --transpile flag with Babel for production use.
affects: >=0.1.0
gotchaWhen using the CLI globally, ensure you have installed decaf globally; local installs may not expose the command.
fix
Use 'npm install decafjs -g' to install globally, or run via 'npx decafjs'.
affects: >=0.1.0
Errors
Common errors & fixes
decaf: command not found
Decaf is not installed globally or not in PATH.
fix
Run 'npm install -g decafjs' or use 'npx decafjs'.
Cannot find module 'decafjs'
Package not installed in the current project.
fix
Run 'npm install decafjs' in your project directory.
TypeError: decaf.compile is not a function
Incorrect import pattern or version mismatch.
fix
Ensure you require/import the default export: const decaf = require('decafjs');
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
coffeescriptrequiredUsed under the hood to parse CoffeeScript and build the syntax tree.
recastrequiredUsed to print the JavaScript output with customizable options.
ast-typesrequiredUsed to build an esprima-compatible abstract syntax tree.
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
bouk-decafjs — npm install bouk-decafjs · libregistry