{
  "source": "doc/api/path.md",
  "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.</p>\n<p>Use <code>require(&#39;path&#39;)</code> to use this module.  The following methods are provided:</p>\n",
      "methods": [
        {
          "textRaw": "path.basename(p[, ext])",
          "type": "method",
          "name": "basename",
          "meta": {
            "added": [
              "v0.1.25"
            ]
          },
          "desc": "<p>Return the last portion of a path.  Similar to the Unix <code>basename</code> command.</p>\n<p>Example:</p>\n<pre><code class=\"lang-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;\n</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "p"
                },
                {
                  "name": "ext",
                  "optional": true
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.dirname(p)",
          "type": "method",
          "name": "dirname",
          "meta": {
            "added": [
              "v0.1.16"
            ]
          },
          "desc": "<p>Return the directory name of a path.  Similar to the Unix <code>dirname</code> command.</p>\n<p>Example:</p>\n<pre><code class=\"lang-js\">path.dirname(&#39;/foo/bar/baz/asdf/quux&#39;)\n// returns &#39;/foo/bar/baz/asdf&#39;\n</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "p"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.extname(p)",
          "type": "method",
          "name": "extname",
          "meta": {
            "added": [
              "v0.1.25"
            ]
          },
          "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:</p>\n<pre><code class=\"lang-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;\n</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "p"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.format(pathObject)",
          "type": "method",
          "name": "format",
          "meta": {
            "added": [
              "v0.11.15"
            ]
          },
          "desc": "<p>Returns a path string from an object, the opposite of [<code>path.parse</code>][].</p>\n<p>Examples:</p>\n<p>Some Posix system examples:</p>\n<pre><code class=\"lang-js\">// If `dir` and `base` are provided, `dir` + platform separator + `base`\n// will be returned.\npath.format({\n    dir: &#39;/home/user/dir&#39;,\n    base: &#39;file.txt&#39;\n});\n// returns &#39;/home/user/dir/file.txt&#39;\n\n// `base` will be returned if `dir` or `root` are not provided.\npath.format({\n    base: &#39;file.txt&#39;\n});\n// returns &#39;file.txt&#39;\n</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "pathObject"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.isAbsolute(path)",
          "type": "method",
          "name": "isAbsolute",
          "meta": {
            "added": [
              "v0.11.2"
            ]
          },
          "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.</p>\n<p>Posix examples:</p>\n<pre><code class=\"lang-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\n</code></pre>\n<p>Windows examples:</p>\n<pre><code class=\"lang-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\n</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.</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "path"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.join([path1][, path2][, ...])",
          "type": "method",
          "name": "join",
          "meta": {
            "added": [
              "v0.1.16"
            ]
          },
          "desc": "<p>Join all arguments together and normalize the resulting path.</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.</p>\n<p>Example:</p>\n<pre><code class=\"lang-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\n</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.</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "path1",
                  "optional": true
                },
                {
                  "name": "path2",
                  "optional": true
                },
                {
                  "name": "...",
                  "optional": true
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.normalize(p)",
          "type": "method",
          "name": "normalize",
          "meta": {
            "added": [
              "v0.1.23"
            ]
          },
          "desc": "<p>Normalize a string path, taking care of <code>&#39;..&#39;</code> and <code>&#39;.&#39;</code> parts.</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.</p>\n<p>Example:</p>\n<pre><code class=\"lang-js\">path.normalize(&#39;/foo/bar//baz/asdf/quux/..&#39;)\n// returns &#39;/foo/bar/baz/asdf&#39;\n</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.</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "p"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.parse(pathString)",
          "type": "method",
          "name": "parse",
          "meta": {
            "added": [
              "v0.11.15"
            ]
          },
          "desc": "<p>Returns an object from a path string.</p>\n<p>An example on *nix:</p>\n<pre><code class=\"lang-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// }\n</code></pre>\n<p>An example on Windows:</p>\n<pre><code class=\"lang-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// }\n</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "pathString"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.relative(from, to)",
          "type": "method",
          "name": "relative",
          "meta": {
            "added": [
              "v0.5.0"
            ]
          },
          "desc": "<p>Solve the relative path from <code>from</code> to <code>to</code>.</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:</p>\n<pre><code class=\"lang-js\">path.resolve(from, path.relative(from, to)) == path.resolve(to)\n</code></pre>\n<p>Examples:</p>\n<pre><code class=\"lang-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;\n</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.</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "from"
                },
                {
                  "name": "to"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "path.resolve([from ...], to)",
          "type": "method",
          "name": "resolve",
          "meta": {
            "added": [
              "v0.3.4"
            ]
          },
          "desc": "<p>Resolves <code>to</code> to an absolute path.</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.</p>\n<p>Another way to think of it is as a sequence of <code>cd</code> commands in a shell.</p>\n<pre><code class=\"lang-js\">path.resolve(&#39;foo/bar&#39;, &#39;/tmp/file/&#39;, &#39;..&#39;, &#39;a/../subfile&#39;)\n</code></pre>\n<p>Is similar to:</p>\n<pre><code>cd foo/bar\ncd /tmp/file/\ncd ..\ncd a/../subfile\npwd\n</code></pre><p>The difference is that the different paths don&#39;t need to exist and may also be\nfiles.</p>\n<p>Examples:</p>\n<pre><code class=\"lang-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;\n</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.</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "from ...",
                  "optional": true
                },
                {
                  "name": "to"
                }
              ]
            }
          ]
        }
      ],
      "properties": [
        {
          "textRaw": "path.delimiter",
          "name": "delimiter",
          "meta": {
            "added": [
              "v0.9.3"
            ]
          },
          "desc": "<p>The platform-specific path delimiter, <code>;</code> or <code>&#39;:&#39;</code>.</p>\n<p>An example on *nix:</p>\n<pre><code class=\"lang-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;]\n</code></pre>\n<p>An example on Windows:</p>\n<pre><code class=\"lang-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;]\n</code></pre>\n"
        },
        {
          "textRaw": "path.posix",
          "name": "posix",
          "meta": {
            "added": [
              "v0.11.15"
            ]
          },
          "desc": "<p>Provide access to aforementioned <code>path</code> methods but always interact in a posix\ncompatible way.</p>\n"
        },
        {
          "textRaw": "path.sep",
          "name": "sep",
          "meta": {
            "added": [
              "v0.7.9"
            ]
          },
          "desc": "<p>The platform-specific file separator. <code>&#39;\\\\&#39;</code> or <code>&#39;/&#39;</code>.</p>\n<p>An example on *nix:</p>\n<pre><code class=\"lang-js\">&#39;foo/bar/baz&#39;.split(path.sep)\n// returns [&#39;foo&#39;, &#39;bar&#39;, &#39;baz&#39;]\n</code></pre>\n<p>An example on Windows:</p>\n<pre><code class=\"lang-js\">&#39;foo\\\\bar\\\\baz&#39;.split(path.sep)\n// returns [&#39;foo&#39;, &#39;bar&#39;, &#39;baz&#39;]\n</code></pre>\n"
        },
        {
          "textRaw": "path.win32",
          "name": "win32",
          "meta": {
            "added": [
              "v0.11.15"
            ]
          },
          "desc": "<p>Provide access to aforementioned <code>path</code> methods but always interact in a win32\ncompatible way.</p>\n"
        }
      ],
      "type": "module",
      "displayName": "Path"
    }
  ]
}
