Skip to content

Instantly share code, notes, and snippets.

@nickstenning
Created July 14, 2010 11:33
Show Gist options
  • Select an option

  • Save nickstenning/475317 to your computer and use it in GitHub Desktop.

Select an option

Save nickstenning/475317 to your computer and use it in GitHub Desktop.
// 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