
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
coffeescript-compiler
Advanced tools
This is a node module which allows you to compile CoffeeScript code (strings of code or files containing code) to JavaScript from JavaScript. Output is provided as a string and can optionally be written out to a file.
You can install this package via npm install coffeescript-compiler
. Please note that this package does NOT define any version of coffee-script
as a dependency for any reason other than testing. You must either have the coffee
command available in your path or have the complete path to access the coffee
command.
All examples assume that you have included this module and created a new Compiler
as follows:
var Compiler = require('coffeescript-compiler');
var cc = new Compiler();
Assuming you have coffee
on your path, compiling a string of CoffeeScript (in this example, a = 5
) is simple:
cc.compile('a = 5', function (status, output) {
if (status === 0) {
// JavaScript available as a string in the `output` variable
}
});
You can get a bare compilation (no wrapper function) by passing in a configuration object as the second argument to compile(...)
:
cc.compile('a = 5', {bare: true}, function (status, output) {
if (status === 0) {
// Bare JavaScript available as a string in the `output` variable
}
});
The configuration object can contain the following options:
asFileName
: If set to true
the first argument passed to compile
is treated as a file name rather than an input string. If this is set and an error is encountered while reading the error will be thrown.bare
: Compiles input to bare JavaScript if set to true
.writeFile
: A string containing a filename to write JavaScript output to. If this is set and an error is encountered while writing the error will be thrown.The MIT License
Copyright (c) 2012 Kenneth Powers
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Compile CoffeeScript code from JavaScript.
The npm package coffeescript-compiler receives a total of 4,203 weekly downloads. As such, coffeescript-compiler popularity was classified as popular.
We found that coffeescript-compiler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.