The first time was attracted, personally feel worth a use, concise, practical, skilled words to write the code itself has become beautiful, and looks very tall on the wood has
Installation
NPM Install Coffee-script-g
NPM is a package management tool for Nodejs, and it can be used with NPM if you download and install Nodejs. - g refers to installing the package into a global path so that you can use it wherever the current path is
Incidentally, how to change the global path
NPM root-g // View global path npm config set prefix path/to/global_modules // set path prefix, NPM will automatically create the Node_modules directory under this directory to store various packages NPM config set cache Path/to/global_cache
Finally, add your Path/to/global_modules path to the system's environment variable and you 're done.
Use
Now you can use the Coffee command in any location.
The most common is to compile the. coffee file into a. js file.
Coffee-o path/to/js/-C path/to/coffee/ // compiles all. coffee files under coffee/to the same name. js file under js/
There are other very useful commands such as listening, etc., see the official website tutorial
Better Coffeescript plugin recommended for players using sublime
Use coffee to write the previous code
Set = (name, value, options = {})ifValue isNULLOptions.maxage= 0Options.expires=-1ifValue andtypeofValue is ' object 'value=json.stringify (value) str= encodeURIComponent (name) + ' = ' +encodeURIComponent (value)ifOptions.expires?D=NewDate () d.settime (D.gettime ()+ options.expires * 1000) Str+ = '; Expires= ' +d.toutcstring ()ifOptions.maxage? Then str + = '; Max-age= ' +Options.maxageifOptions.path? Then str + = '; Path= ' +Options.pathifOptions.domain? Then str + = '; Domain= ' +Options.domainifOptions.secure? Then str + = '; SecureDocument.cookie= str
For Coffeescript I personally feel that the need to spit groove is the official code in the call function when the parameters () are omitted, so that the readability is significantly worse, when writing is still more comfortable with parentheses
Coffeescript First Experience