-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathpath.json
148 lines (148 loc) · 7.76 KB
/
path.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{
"source": "doc/api/path.markdown",
"modules": [
{
"textRaw": "Path",
"name": "path",
"stability": 3,
"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('path')</code> to use this module. The following methods are provided:\n\n</p>\n",
"methods": [
{
"textRaw": "path.normalize(p)",
"type": "method",
"name": "normalize",
"desc": "<p>Normalize a string path, taking care of <code>'..'</code> and <code>'.'</code> parts.\n\n</p>\n<p>When multiple slashes are found, they'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>path.normalize('/foo/bar//baz/asdf/quux/..')\n// returns\n'/foo/bar/baz/asdf'</code></pre>\n",
"signatures": [
{
"params": [
{
"name": "p"
}
]
}
]
},
{
"textRaw": "path.join([path1], [path2], [...])",
"type": "method",
"name": "join",
"desc": "<p>Join all arguments together and normalize the resulting path.\nNon-string arguments are ignored.\n\n</p>\n<p>Example:\n\n</p>\n<pre><code>path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')\n// returns\n'/foo/bar/baz/asdf'\n\npath.join('foo', {}, 'bar')\n// returns\n'foo/bar'</code></pre>\n",
"signatures": [
{
"params": [
{
"name": "path1",
"optional": true
},
{
"name": "path2",
"optional": true
},
{
"name": "...",
"optional": true
}
]
}
]
},
{
"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'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 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>path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile')</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't need to exist and may also be\nfiles.\n\n</p>\n<p>Examples:\n\n</p>\n<pre><code>path.resolve('/foo/bar', './baz')\n// returns\n'/foo/bar/baz'\n\npath.resolve('/foo/bar', '/tmp/file/')\n// returns\n'/tmp/file'\n\npath.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')\n// if currently in /home/myself/node, it returns\n'/home/myself/node/wwwroot/static_files/gif/image.gif'</code></pre>\n",
"signatures": [
{
"params": [
{
"name": "from ...",
"optional": true
},
{
"name": "to"
}
]
}
]
},
{
"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>path.resolve(from, path.relative(from, to)) == path.resolve(to)</code></pre>\n<p>Examples:\n\n</p>\n<pre><code>path.relative('C:\\\\orandea\\\\test\\\\aaa', 'C:\\\\orandea\\\\impl\\\\bbb')\n// returns\n'..\\\\..\\\\impl\\\\bbb'\n\npath.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')\n// returns\n'../../impl/bbb'</code></pre>\n",
"signatures": [
{
"params": [
{
"name": "from"
},
{
"name": "to"
}
]
}
]
},
{
"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>path.dirname('/foo/bar/baz/asdf/quux')\n// returns\n'/foo/bar/baz/asdf'</code></pre>\n",
"signatures": [
{
"params": [
{
"name": "p"
}
]
}
]
},
{
"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>path.basename('/foo/bar/baz/asdf/quux.html')\n// returns\n'quux.html'\n\npath.basename('/foo/bar/baz/asdf/quux.html', '.html')\n// returns\n'quux'</code></pre>\n",
"signatures": [
{
"params": [
{
"name": "p"
},
{
"name": "ext",
"optional": true
}
]
}
]
},
{
"textRaw": "path.extname(p)",
"type": "method",
"name": "extname",
"desc": "<p>Return the extension of the path, from the last '.' to end of string\nin the last portion of the path. If there is no '.' in the last portion\nof the path or the first character of it is '.', then it returns\nan empty string. Examples:\n\n</p>\n<pre><code>path.extname('index.html')\n// returns\n'.html'\n\npath.extname('index.')\n// returns\n'.'\n\npath.extname('index')\n// returns\n''</code></pre>\n",
"signatures": [
{
"params": [
{
"name": "p"
}
]
}
]
}
],
"properties": [
{
"textRaw": "path.sep",
"name": "sep",
"desc": "<p>The platform-specific file separator. <code>'\\\\'</code> or <code>'/'</code>.\n\n</p>\n<p>An example on linux:\n\n</p>\n<pre><code>'foo/bar/baz'.split(path.sep)\n// returns\n['foo', 'bar', 'baz']</code></pre>\n<p>An example on windows:\n\n</p>\n<pre><code>'foo\\\\bar\\\\baz'.split(path.sep)\n// returns\n['foo', 'bar', 'baz']</code></pre>\n"
}
],
"type": "module",
"displayName": "Path"
}
]
}