{
  "source": "doc/api/path.markdown",
  "modules": [
    {
      "textRaw": "Path",
      "name": "path",
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p>This module contains utilities for handling and transforming file\npaths.  Almost all these methods perform only string transformations.\nThe file system is not consulted to check whether paths are valid.\n\n</p>\n<p>Use <code>require(&#39;path&#39;)</code> to use this module.  The following methods are provided:\n\n</p>\n",
      "methods": [
        {
          "textRaw": "path.basename(p[, ext])",
          "type": "method",
          "name": "basename",
          "desc": "<p>Return the last portion of a path.  Similar to the Unix <code>basename</code> command.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code class=\"js\">path.basename(&#39;/foo/bar/baz/asdf/quux.html&#39;)\n// returns &#39;quux.html&#39;\n\npath.basename(&#39;/foo/bar/baz/asdf/quux.html&#39;, &#39;.html&#39;)\n// returns &#39;quux&#39;</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "p"
                },
                {
                  "name": "ext",
                  "optional": true
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.dirname(p)",
          "type": "method",
          "name": "dirname",
          "desc": "<p>Return the directory name of a path.  Similar to the Unix <code>dirname</code> command.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code class=\"js\">path.dirname(&#39;/foo/bar/baz/asdf/quux&#39;)\n// returns &#39;/foo/bar/baz/asdf&#39;</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "p"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.extname(p)",
          "type": "method",
          "name": "extname",
          "desc": "<p>Return the extension of the path, from the last &#39;.&#39; to end of string\nin the last portion of the path.  If there is no &#39;.&#39; in the last portion\nof the path or the first character of it is &#39;.&#39;, then it returns\nan empty string.  Examples:\n\n</p>\n<pre><code class=\"js\">path.extname(&#39;index.html&#39;)\n// returns &#39;.html&#39;\n\npath.extname(&#39;index.coffee.md&#39;)\n// returns &#39;.md&#39;\n\npath.extname(&#39;index.&#39;)\n// returns &#39;.&#39;\n\npath.extname(&#39;index&#39;)\n// returns &#39;&#39;\n\npath.extname(&#39;.index&#39;)\n// returns &#39;&#39;</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "p"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.format(pathObject)",
          "type": "method",
          "name": "format",
          "desc": "<p>Returns a path string from an object. This is the opposite of [<code>path.parse</code>][].\n\n</p>\n<p>If <code>pathObject</code> has all expected properties, the returned string will be a\nconcatenation of the <code>dir</code> property, the platform-dependent path separator, and\nthe <code>base</code> property.\n\n</p>\n<p>If the <code>dir</code> property is not supplied, the <code>root</code> property will be used as the\n<code>dir</code> property. However, it will be assumed that the <code>root</code> property already\nends with the platform-dependent path separator. In this case, the returned\nstring will be the concatenation fo the <code>root</code> property and the <code>base</code> property.\n\n</p>\n<p>If both the <code>dir</code> and the <code>root</code> properties are not supplied, then the returned\nstring will be the contents of the <code>base</code> property.\n\n</p>\n<p>If the <code>base</code> property is not supplied, a concatenation of the <code>name</code> property\nand the <code>ext</code> property will be used as the <code>base</code> property.\n\n</p>\n<pre><code class=\"js\">path.format({\n    root : &quot;/&quot;,\n    dir : &quot;/home/user/dir&quot;,\n    base : &quot;file.txt&quot;,\n    ext : &quot;.txt&quot;,\n    name : &quot;file&quot;\n});\n// returns &#39;/home/user/dir/file.txt&#39;\n\n// `root` will be used if `dir` is not specified and `name` + `ext` will be used\n// if `base` is not specified\npath.format({\n    root : &quot;/&quot;,\n    ext : &quot;.txt&quot;,\n    name : &quot;file&quot;\n})\n// returns &#39;/file.txt&#39;</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "pathObject"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.isAbsolute(path)",
          "type": "method",
          "name": "isAbsolute",
          "desc": "<p>Determines whether <code>path</code> is an absolute path. An absolute path will always\nresolve to the same location, regardless of the working directory.\n\n</p>\n<p>Posix examples:\n\n</p>\n<pre><code class=\"js\">path.isAbsolute(&#39;/foo/bar&#39;) // true\npath.isAbsolute(&#39;/baz/..&#39;)  // true\npath.isAbsolute(&#39;qux/&#39;)     // false\npath.isAbsolute(&#39;.&#39;)        // false</code></pre>\n<p>Windows examples:\n\n</p>\n<pre><code class=\"js\">path.isAbsolute(&#39;//server&#39;)  // true\npath.isAbsolute(&#39;C:/foo/..&#39;) // true\npath.isAbsolute(&#39;bar\\\\baz&#39;)  // false\npath.isAbsolute(&#39;.&#39;)         // false</code></pre>\n<p><em>Note:</em> If the path string passed as parameter is a zero-length string, unlike\n        other path module functions, it will be used as-is and <code>false</code> will be\n        returned.\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "path"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.join([path1][, path2][, ...])",
          "type": "method",
          "name": "join",
          "desc": "<p>Join all arguments together and normalize the resulting path.\n\n</p>\n<p>Arguments must be strings.  In v0.8, non-string arguments were\nsilently ignored.  In v0.10 and up, an exception is thrown.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code class=\"js\">path.join(&#39;/foo&#39;, &#39;bar&#39;, &#39;baz/asdf&#39;, &#39;quux&#39;, &#39;..&#39;)\n// returns &#39;/foo/bar/baz/asdf&#39;\n\npath.join(&#39;foo&#39;, {}, &#39;bar&#39;)\n// throws exception\nTypeError: Arguments to path.join must be strings</code></pre>\n<p><em>Note:</em> If the arguments to <code>join</code> have zero-length strings, unlike other path\n        module functions, they will be ignored. If the joined path string is a\n        zero-length string then <code>&#39;.&#39;</code> will be returned, which represents the\n        current working directory.\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "path1",
                  "optional": true
                },
                {
                  "name": "path2",
                  "optional": true
                },
                {
                  "name": "...",
                  "optional": true
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.normalize(p)",
          "type": "method",
          "name": "normalize",
          "desc": "<p>Normalize a string path, taking care of <code>&#39;..&#39;</code> and <code>&#39;.&#39;</code> parts.\n\n</p>\n<p>When multiple slashes are found, they&#39;re replaced by a single one;\nwhen the path contains a trailing slash, it is preserved.\nOn Windows backslashes are used.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code class=\"js\">path.normalize(&#39;/foo/bar//baz/asdf/quux/..&#39;)\n// returns &#39;/foo/bar/baz/asdf&#39;</code></pre>\n<p><em>Note:</em> If the path string passed as argument is a zero-length string then <code>&#39;.&#39;</code>\n        will be returned, which represents the current working directory.\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "p"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.parse(pathString)",
          "type": "method",
          "name": "parse",
          "desc": "<p>Returns an object from a path string.\n\n</p>\n<p>An example on *nix:\n\n</p>\n<pre><code class=\"js\">path.parse(&#39;/home/user/dir/file.txt&#39;)\n// returns\n// {\n//    root : &quot;/&quot;,\n//    dir : &quot;/home/user/dir&quot;,\n//    base : &quot;file.txt&quot;,\n//    ext : &quot;.txt&quot;,\n//    name : &quot;file&quot;\n// }</code></pre>\n<p>An example on Windows:\n\n</p>\n<pre><code class=\"js\">path.parse(&#39;C:\\\\path\\\\dir\\\\index.html&#39;)\n// returns\n// {\n//    root : &quot;C:\\\\&quot;,\n//    dir : &quot;C:\\\\path\\\\dir&quot;,\n//    base : &quot;index.html&quot;,\n//    ext : &quot;.html&quot;,\n//    name : &quot;index&quot;\n// }</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "pathString"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.relative(from, to)",
          "type": "method",
          "name": "relative",
          "desc": "<p>Solve the relative path from <code>from</code> to <code>to</code>.\n\n</p>\n<p>At times we have two absolute paths, and we need to derive the relative\npath from one to the other.  This is actually the reverse transform of\n<code>path.resolve</code>, which means we see that:\n\n</p>\n<pre><code class=\"js\">path.resolve(from, path.relative(from, to)) == path.resolve(to)</code></pre>\n<p>Examples:\n\n</p>\n<pre><code class=\"js\">path.relative(&#39;C:\\\\orandea\\\\test\\\\aaa&#39;, &#39;C:\\\\orandea\\\\impl\\\\bbb&#39;)\n// returns &#39;..\\\\..\\\\impl\\\\bbb&#39;\n\npath.relative(&#39;/data/orandea/test/aaa&#39;, &#39;/data/orandea/impl/bbb&#39;)\n// returns &#39;../../impl/bbb&#39;</code></pre>\n<p><em>Note:</em> If the arguments to <code>relative</code> have zero-length strings then the current\n        working directory will be used instead of the zero-length strings. If\n        both the paths are the same then a zero-length string will be returned.\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "from"
                },
                {
                  "name": "to"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.resolve([from ...], to)",
          "type": "method",
          "name": "resolve",
          "desc": "<p>Resolves <code>to</code> to an absolute path.\n\n</p>\n<p>If <code>to</code> isn&#39;t already absolute <code>from</code> arguments are prepended in right to left\norder, until an absolute path is found. If after using all <code>from</code> paths still\nno absolute path is found, the current working directory is used as well. The\nresulting path is normalized, and trailing slashes are removed unless the path\ngets resolved to the root directory. Non-string <code>from</code> arguments are ignored.\n\n</p>\n<p>Another way to think of it is as a sequence of <code>cd</code> commands in a shell.\n\n</p>\n<pre><code class=\"js\">path.resolve(&#39;foo/bar&#39;, &#39;/tmp/file/&#39;, &#39;..&#39;, &#39;a/../subfile&#39;)</code></pre>\n<p>Is similar to:\n\n</p>\n<pre><code>cd foo/bar\ncd /tmp/file/\ncd ..\ncd a/../subfile\npwd</code></pre>\n<p>The difference is that the different paths don&#39;t need to exist and may also be\nfiles.\n\n</p>\n<p>Examples:\n\n</p>\n<pre><code class=\"js\">path.resolve(&#39;/foo/bar&#39;, &#39;./baz&#39;)\n// returns &#39;/foo/bar/baz&#39;\n\npath.resolve(&#39;/foo/bar&#39;, &#39;/tmp/file/&#39;)\n// returns &#39;/tmp/file&#39;\n\npath.resolve(&#39;wwwroot&#39;, &#39;static_files/png/&#39;, &#39;../gif/image.gif&#39;)\n// if currently in /home/myself/node, it returns\n// &#39;/home/myself/node/wwwroot/static_files/gif/image.gif&#39;</code></pre>\n<p><em>Note:</em> If the arguments to <code>resolve</code> have zero-length strings then the current\n        working directory will be used instead of them.\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "from ...",
                  "optional": true
                },
                {
                  "name": "to"
                }
              ]
            }
          ]
        }
      ],
      "properties": [
        {
          "textRaw": "path.delimiter",
          "name": "delimiter",
          "desc": "<p>The platform-specific path delimiter, <code>;</code> or <code>&#39;:&#39;</code>.\n\n</p>\n<p>An example on *nix:\n\n</p>\n<pre><code class=\"js\">console.log(process.env.PATH)\n// &#39;/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin&#39;\n\nprocess.env.PATH.split(path.delimiter)\n// returns [&#39;/usr/bin&#39;, &#39;/bin&#39;, &#39;/usr/sbin&#39;, &#39;/sbin&#39;, &#39;/usr/local/bin&#39;]</code></pre>\n<p>An example on Windows:\n\n</p>\n<pre><code class=\"js\">console.log(process.env.PATH)\n// &#39;C:\\Windows\\system32;C:\\Windows;C:\\Program Files\\node\\&#39;\n\nprocess.env.PATH.split(path.delimiter)\n// returns [&#39;C:\\\\Windows\\\\system32&#39;, &#39;C:\\\\Windows&#39;, &#39;C:\\\\Program Files\\\\node\\\\&#39;]</code></pre>\n"
        },
        {
          "textRaw": "path.posix",
          "name": "posix",
          "desc": "<p>Provide access to aforementioned <code>path</code> methods but always interact in a posix\ncompatible way.\n\n</p>\n"
        },
        {
          "textRaw": "path.sep",
          "name": "sep",
          "desc": "<p>The platform-specific file separator. <code>&#39;\\\\&#39;</code> or <code>&#39;/&#39;</code>.\n\n</p>\n<p>An example on *nix:\n\n</p>\n<pre><code class=\"js\">&#39;foo/bar/baz&#39;.split(path.sep)\n// returns [&#39;foo&#39;, &#39;bar&#39;, &#39;baz&#39;]</code></pre>\n<p>An example on Windows:\n\n</p>\n<pre><code class=\"js\">&#39;foo\\\\bar\\\\baz&#39;.split(path.sep)\n// returns [&#39;foo&#39;, &#39;bar&#39;, &#39;baz&#39;]</code></pre>\n"
        },
        {
          "textRaw": "path.win32",
          "name": "win32",
          "desc": "<p>Provide access to aforementioned <code>path</code> methods but always interact in a win32\ncompatible way.\n\n</p>\n"
        }
      ],
      "type": "module",
      "displayName": "Path"
    }
  ]
}
