Improvements:
* Removes an unnecessary variable
* Avoids having two variables with the same name
* Avoids re-declaring an existing parameter
* Removes an unnecessary ternary operator
* Avoid an inline short-circuit expression for greater clarity.
Problem: Omitting the mode parameter causes the provided callback
parameter to never fire. This was originally fixed in 6078c37b and
later broken in 5f2e9093.
Solution: Overwriting the value of a parameter also overwrites the
reference in the arguments object. This patch works arround this
fact by not touching the mode parameter until a reference to the
callback has been established.
This adds support for a cache object to be passed to the
fs.realpath and fs.realpathSync functions. The Module loader keeps an
object around which caches the resulting realpaths that it looks up in
the process of loading modules.
This means that (at least as a result of loading modules) the same files
and folders are never lstat()ed more than once. To reset the cache, set
require("module")._realpathCache to an empty object. To disable the
caching behavior, set it to null.
This allows the various fs utilities and process.umask to be used in
ECMAScript 5 Strict Mode, where the octal literal format is verboten,
without requiring users to litter their code with a bunch of parseInt
calls.
1. Express desired path.join behavior in tests.
2. Update fs.realpath to reflect new path.join behavior
3. Update url.resolve() to use new path.join behavior.
writeFileSync could exhibit pathological behavior when a buffer could
not be written to the file in a single write() call.
Also, writeFile was not quite as optimized as it could be.
Rather than aborting in the face of *any* repeated link in a given path,
instead only abort if such a cycle actually makes a given path unresolvable.
Test for this by doing a normal stat. Still use the seenLinks object to
cache link contents so as to cut own a little bit on readlink calls.
Also add a pathological test that fails without the change to fs.js.