Created
March 17, 2010 11:55
-
-
Save drnic/335155 to your computer and use it in GitHub Desktop.
Comparing a NodeJS example rewritten as CoffeeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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