Registry / data / js2coffee

js2coffee

JSON →
library2.2.0jsnpmunverified

JavaScript to CoffeeScript compiler. v2.2.0 (latest) rewrites the 0.x series with a new Esprima-based parser, offering better JavaScript coverage. Released on npm and Bower. Key differentiator: unidirectional conversion from JS to CoffeeScript with warnings for unrepresentable patterns.

npm install js2coffee
INSTALL
IMPORT
SIG · JS2COFFEE
J
js2coffee
datajavascriptv2.2.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.

js2coffee
const js2coffee = require('js2coffee')
import js2coffee from 'js2coffee' (ESM not supported)
CommonJS only. Use require() or window.js2coffee for browser.
build
js2coffee.build(source)
js2coffee(source)
build is the main API method returning { code, ast, map, warnings }
version
js2coffee.version (string)
Read-only property exposing library version

Compile JavaScript to CoffeeScript using the build method, outputting CoffeeScript code.

const js2coffee = require('js2coffee'); const source = ` var x = 1; function hello(name) { console.log('Hello, ' + name); } hello('world'); `; const result = js2coffee.build(source); console.log(result.code); // x = 1 // hello = (name) -> // console.log 'Hello, ' + name // hello 'world'
js2coffee --version
Debug
Known issues
breaking2.0 release rewrites API: 0.x `js2coffee.js2coffee()` no longer works
fix
Use `js2coffee.build()` instead of the old `js2coffee.js2coffee()`
affects: >=2.0
deprecated0.x series is deprecated. No longer supported.
fix
Upgrade to v2.x using the migration guide
affects: <2.0
gotchaNot all JavaScript constructs convert cleanly; result.warnings may contain warnings for unrepresentable patterns
fix
Check result.warnings array after conversion and handle accordingly
affects: >=2.0
Errors
Common errors & fixes
Cannot find module 'js2coffee'
Package not installed
fix
npm install js2coffee
js2coffee is not a function
v2.x does not have a default export
fix
Use js2coffee.build() instead of trying to call js2coffee()
require(...).js2coffee is not a function
0.x API does not exist in v2
fix
Update to js2coffee.build() for v2
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies
esprimarequiredJavaScript parser used to parse input
Agent activity
4 hits · last 30 days
node
4
Resources
js2coffee — npm install js2coffee · libregistry