Skip to content

Instantly share code, notes, and snippets.

@drnic
Created March 17, 2010 11:55
Show Gist options
  • Select an option

  • Save drnic/335155 to your computer and use it in GitHub Desktop.

Select an option

Save drnic/335155 to your computer and use it in GitHub Desktop.
Comparing a NodeJS example rewritten as CoffeeScript
# CoffeeScript version of NodeJS example from http://nodejs.org/api.html#_file_system
sys: require('sys')
fs: require('fs')
fs.rename "/tmp/hello", "/tmp/world", (err) ->
throw err if err
fs.stat "/tmp/world", (err, stats) ->
throw err if err
sys.puts "stats: ${JSON.stringify(stats)}"
fs.rename "/tmp/world", "/tmp/hello", (err) ->
throw err if err
// NodeJS example from http://nodejs.org/api.html#_file_system
var fs = require('fs');
var sys = require('sys');
fs.rename("/tmp/hello", "/tmp/world", function (err) {
if (err) throw err;
fs.stat("/tmp/world", function (err, stats) {
if (err) throw err;
sys.puts("stats: " + JSON.stringify(stats));
fs.rename("/tmp/world", "/tmp/hello", function (err) {
if (err) throw err;
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment