@@ -83,22 +83,7 @@ path.extname('.index')
83
83
84
84
## path.format(pathObject)
85
85
86
- Returns a path string from an object. This is the opposite of [ ` path.parse ` ] [ ] .
87
-
88
- If ` pathObject ` has ` dir ` and ` base ` properties, the returned string will
89
- be a concatenation of the ` dir ` property, the platform-dependent path separator,
90
- and the ` base ` property.
91
-
92
- If the ` dir ` property is not supplied, the ` root ` property will be used as the
93
- ` dir ` property. However, it will be assumed that the ` root ` property already
94
- ends with the platform-dependent path separator. In this case, the returned
95
- string will be the concatenation of the ` root ` property and the ` base ` property.
96
-
97
- If both the ` dir ` and the ` root ` properties are not supplied, then the returned
98
- string will be the contents of the ` base ` property.
99
-
100
- If the ` base ` property is not supplied, a concatenation of the ` name ` property
101
- and the ` ext ` property will be used as the ` base ` property.
86
+ Returns a path string from an object, the opposite of [ ` path.parse ` ] [ ] .
102
87
103
88
Examples:
104
89
@@ -113,42 +98,12 @@ path.format({
113
98
});
114
99
// returns '/home/user/dir/file.txt'
115
100
116
- // `root` will be used if `dir` is not specified.
117
- // `name` + `ext` will be used if `base` is not specified.
118
- // If only `root` is provided or `dir` is equal to `root` then the
119
- // platform separator will not be included.
120
- path .format ({
121
- root: ' /' ,
122
- base: ' file.txt'
123
- });
124
- // returns '/file.txt'
125
-
126
- path .format ({
127
- dir: ' /' ,
128
- root: ' /' ,
129
- name: ' file' ,
130
- ext: ' .txt'
131
- });
132
- // returns '/file.txt'
133
-
134
101
// `base` will be returned if `dir` or `root` are not provided.
135
102
path .format ({
136
103
base: ' file.txt'
137
104
});
138
105
// returns 'file.txt'
139
106
```
140
- An example on Windows:
141
-
142
- ``` js
143
- path .format ({
144
- root : " C:\\ " ,
145
- dir : " C:\\ path\\ dir" ,
146
- base : " file.txt" ,
147
- ext : " .txt" ,
148
- name : " file"
149
- })
150
- // returns 'C:\\path\\dir\\file.txt'
151
- ```
152
107
153
108
## path.isAbsolute(path)
154
109
0 commit comments