fs: fix 'object is not a function' callback errors
authorBen Noordhuis <info@bnoordhuis.nl>
Tue, 4 Dec 2012 02:17:52 +0000 (03:17 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 4 Dec 2012 07:05:55 +0000 (08:05 +0100)
commita80434736bce22a9ac00376bb5786806752ef3dd
tree3d4c79320621850a42660aa3776e510923c50a87
parent03b00dcca912ae2dba515fb05221f2245e829479
fs: fix 'object is not a function' callback errors

Use a default callback if the user omitted one. Avoids errors like the one
below:

  fs.js:777
      if (err) return callback(err);
                      ^
  TypeError: object is not a function
          at fs.appendFile (fs.js:777:21)
          at Object.oncomplete (fs.js:297:15)

This commit fixes the behavior of fs.lchmod(), fs.lchown() and fs.readFile()
when the callback is omitted. Before, they silently swallowed errors.

Fixes #4352.
doc/api/fs.markdown
lib/fs.js