FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-api-cn/path/path_parse_path.md at master · nodejscn/node-api-cn · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
nodejscn
/
node-api-cn
Public
Notifications
You must be signed in to change notification settings
Fork
1.3k
Star
1.4k
Code
Issues
1
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node-api-cn
/
path
/
path_parse_path.md
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (52 loc) · 1.83 KB
Breadcrumbs
node-api-cn
/
path
/
path_parse_path.md
Copy path
File metadata and controls
64 lines (52 loc) · 1.83 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<!-- YAML
added:
v0
.11
.15
-->
*
`path`
{
string
}
*
返回:
{
Object
}
`path.parse()`
方法会返回一个对象,其属性表示
`path`
的有效元素。
尾部的目录分隔符会被忽略,参见
[
`path.sep`
]
。
返回的对象具有以下属性:
*
`dir`
{
string
}
*
`root`
{
string
}
*
`base`
{
string
}
*
`name`
{
string
}
*
`ext`
{
string
}
例如,在
POSIX
上:
``
`js
path.parse('/目录1/目录2/文件.txt');
// 返回:
// { root: '/',
// dir: '/目录1/目录2',
// base: '文件.txt',
// ext: '.txt',
// name: '文件' }
`
``
``
`text
┌─────────────────────┬────────────┐
│ dir │ base │
├──────┬ ├──────┬─────┤
│ root │ │ name │ ext │
" / 目录1/目录2 / 文件 .txt "
└──────┴──────────────┴──────┴─────┘
("" 行中的所有空格均可忽略。它们纯粹是用于格式化。)
`
``
在
Windows
上:
``
`js
path.parse('C:\\目录1\\目录2\\文件.txt');
// 返回:
// { root: 'C:\\',
// dir: 'C:\\目录1\\目录2',
// base: '文件.txt',
// ext: '.txt',
// name: '文件' }
`
``
``
`text
┌─────────────────────┬────────────┐
│ dir │ base │
├──────┬ ├──────┬─────┤
│ root │ │ name │ ext │
" C:\ 目录1\目录2 \ 文件 .txt "
└──────┴──────────────┴──────┴─────┘
("" 行中的所有空格均可忽略。它们纯粹是用于格式化。)
`
``
如果
`path`
不是字符串,则抛出
[
`TypeError`
]
。
Back
|
FazBrowse Home
|
New Git URL