Created
July 14, 2010 11:33
-
-
Save nickstenning/475317 to your computer and use it in GitHub Desktop.
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
| // Before running this file, do `touch foo` in the same directory. | |
| var fs = require('fs'), | |
| sys = require('sys'); | |
| var f = fs.readFileSync('foo', 'utf8'); | |
| sys.puts("sync: " + sys.inspect(f)); | |
| fs.readFile('foo', 'utf8', function (err, data) { | |
| sys.puts("async: " + sys.inspect(data)); | |
| }); | |
| // Expected behaviour | |
| // both return the empty string: '' | |
| // | |
| // Actual behaviour | |
| // async returns an empty Buffer: <Buffer > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment