Skip to content

Commit

Permalink
Documentation for path module
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs authored and ry committed Jan 5, 2010
1 parent 7342fec commit d6fe7fb
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions doc/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,73 @@ Expects +block+ to throw an error.
+assert.doesNotThrow(block, error, message)+::
Expects +block+ not to throw an error.


=== Path Module

This module contains utilities for dealing with file paths. Use
+require('path')+ to use it. It provides the following methods:

+path.join(/* path1, path2, ... */)+::
Join all arguments together and resolve the resulting path. Example:
+
------------------------------------
node> require("path").join("/foo", "bar", "baz/asdf", "quux", "..")
"/foo/bar/baz/asdf"
------------------------------------
+

+path.normalizeArray(arr)+::
Normalize an array of path parts, taking care of +".."+ and +"."+ parts. Example:
+
------------------------------------
node> require("path").normalizeArray(["", "foo", "bar", "baz", "asdf", "quux", ".."])
[
"",
"foo",
"bar",
"baz",
"asdf"
]
------------------------------------
+

+path.normalize(p)+::
Normalize a string path, taking care of +".."+ and +"."+ parts. Example:
+
------------------------------------
node> require("path").normalize("/foo/bar/baz/asdf/quux/..")
"/foo/bar/baz/asdf"
------------------------------------
+

+path.dirname(p)+::
Return the directory name of a path. Similar to the Unix +dirname+ command. Example:
+
------------------------------------
node> require("path").dirname("/foo/bar/baz/asdf/quux")
"/foo/bar/baz/asdf"
------------------------------------
+

+path.filename(p)+::
Return the last portion of a path. Similar to the Unix +basename+ command. Example:
+
------------------------------------
node> require("path").filename("/foo/bar/baz/asdf/quux")
"quux"
------------------------------------
+

+path.exists(p, callback)+::
Test whether or not the given path exists. Then, call the +callback+ argument with either true or false. Example:
+
------------------------------------
require("path").exists("/etc/passwd", function (exists) {
require("sys").debug( exists ? "it's there" : "no passwd!" );
});
------------------------------------


== REPL

A Read-Eval-Print-Loop is available both as a standalone program and easily
Expand Down

0 comments on commit d6fe7fb

Please sign in to comment.