@@ -112,6 +112,17 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
112
112
return res ;
113
113
}
114
114
115
+ /**
116
+ * @param {string } sep
117
+ * @param {{
118
+ * dir?: string;
119
+ * root?: string;
120
+ * base?: string;
121
+ * name?: string;
122
+ * ext?: string;
123
+ * }} pathObject
124
+ * @returns {string }
125
+ */
115
126
function _format ( sep , pathObject ) {
116
127
if ( pathObject === null || typeof pathObject !== 'object' ) {
117
128
throw new ERR_INVALID_ARG_TYPE ( 'pathObject' , 'Object' , pathObject ) ;
@@ -126,7 +137,11 @@ function _format(sep, pathObject) {
126
137
}
127
138
128
139
const win32 = {
129
- // path.resolve([from ...], to)
140
+ /**
141
+ * path.resolve([from ...], to)
142
+ * @param {...string } args
143
+ * @returns {string }
144
+ */
130
145
resolve ( ...args ) {
131
146
let resolvedDevice = '' ;
132
147
let resolvedTail = '' ;
@@ -262,6 +277,10 @@ const win32 = {
262
277
`${ resolvedDevice } ${ resolvedTail } ` || '.' ;
263
278
} ,
264
279
280
+ /**
281
+ * @param {string } path
282
+ * @returns {string }
283
+ */
265
284
normalize ( path ) {
266
285
validateString ( path , 'path' ) ;
267
286
const len = path . length ;
@@ -349,6 +368,10 @@ const win32 = {
349
368
return isAbsolute ? `${ device } \\${ tail } ` : `${ device } ${ tail } ` ;
350
369
} ,
351
370
371
+ /**
372
+ * @param {string } path
373
+ * @returns {boolean }
374
+ */
352
375
isAbsolute ( path ) {
353
376
validateString ( path , 'path' ) ;
354
377
const len = path . length ;
@@ -364,6 +387,10 @@ const win32 = {
364
387
isPathSeparator ( path . charCodeAt ( 2 ) ) ) ;
365
388
} ,
366
389
390
+ /**
391
+ * @param {...string } args
392
+ * @returns {string }
393
+ */
367
394
join ( ...args ) {
368
395
if ( args . length === 0 )
369
396
return '.' ;
@@ -429,10 +456,15 @@ const win32 = {
429
456
return win32 . normalize ( joined ) ;
430
457
} ,
431
458
432
- // It will solve the relative path from `from` to `to`, for instance:
433
- // from = 'C:\\orandea\\test\\aaa'
434
- // to = 'C:\\orandea\\impl\\bbb'
435
- // The output of the function should be: '..\\..\\impl\\bbb'
459
+ /**
460
+ * It will solve the relative path from `from` to `to`, for instancee
461
+ * from = 'C:\\orandea\\test\\aaa'
462
+ * to = 'C:\\orandea\\impl\\bbb'
463
+ * The output of the function should be: '..\\..\\impl\\bbb'
464
+ * @param {string } from
465
+ * @param {string } to
466
+ * @returns {string }
467
+ */
436
468
relative ( from , to ) {
437
469
validateString ( from , 'from' ) ;
438
470
validateString ( to , 'to' ) ;
@@ -579,6 +611,10 @@ const win32 = {
579
611
return path ;
580
612
} ,
581
613
614
+ /**
615
+ * @param {string } path
616
+ * @returns {string }
617
+ */
582
618
dirname ( path ) {
583
619
validateString ( path , 'path' ) ;
584
620
const len = path . length ;
@@ -665,6 +701,11 @@ const win32 = {
665
701
return path . slice ( 0 , end ) ;
666
702
} ,
667
703
704
+ /**
705
+ * @param {string } path
706
+ * @param {string } [ext]
707
+ * @returns {string }
708
+ */
668
709
basename ( path , ext ) {
669
710
if ( ext !== undefined )
670
711
validateString ( ext , 'ext' ) ;
@@ -748,6 +789,10 @@ const win32 = {
748
789
return path . slice ( start , end ) ;
749
790
} ,
750
791
792
+ /**
793
+ * @param {string } path
794
+ * @returns {string }
795
+ */
751
796
extname ( path ) {
752
797
validateString ( path , 'path' ) ;
753
798
let start = 0 ;
@@ -814,6 +859,16 @@ const win32 = {
814
859
815
860
format : _format . bind ( null , '\\' ) ,
816
861
862
+ /**
863
+ * @param {string } path
864
+ * @returns {{
865
+ * dir: string;
866
+ * root: string;
867
+ * base: string;
868
+ * name: string;
869
+ * ext: string;
870
+ * }}
871
+ */
817
872
parse ( path ) {
818
873
validateString ( path , 'path' ) ;
819
874
@@ -969,7 +1024,11 @@ const win32 = {
969
1024
} ;
970
1025
971
1026
const posix = {
972
- // path.resolve([from ...], to)
1027
+ /**
1028
+ * path.resolve([from ...], to)
1029
+ * @param {...string } args
1030
+ * @returns {string }
1031
+ */
973
1032
resolve ( ...args ) {
974
1033
let resolvedPath = '' ;
975
1034
let resolvedAbsolute = false ;
@@ -1001,6 +1060,10 @@ const posix = {
1001
1060
return resolvedPath . length > 0 ? resolvedPath : '.' ;
1002
1061
} ,
1003
1062
1063
+ /**
1064
+ * @param {string } path
1065
+ * @returns {string }
1066
+ */
1004
1067
normalize ( path ) {
1005
1068
validateString ( path , 'path' ) ;
1006
1069
@@ -1025,11 +1088,19 @@ const posix = {
1025
1088
return isAbsolute ? `/${ path } ` : path ;
1026
1089
} ,
1027
1090
1091
+ /**
1092
+ * @param {string } path
1093
+ * @returns {boolean }
1094
+ */
1028
1095
isAbsolute ( path ) {
1029
1096
validateString ( path , 'path' ) ;
1030
1097
return path . length > 0 && path . charCodeAt ( 0 ) === CHAR_FORWARD_SLASH ;
1031
1098
} ,
1032
1099
1100
+ /**
1101
+ * @param {...string } args
1102
+ * @returns {string }
1103
+ */
1033
1104
join ( ...args ) {
1034
1105
if ( args . length === 0 )
1035
1106
return '.' ;
@@ -1049,6 +1120,11 @@ const posix = {
1049
1120
return posix . normalize ( joined ) ;
1050
1121
} ,
1051
1122
1123
+ /**
1124
+ * @param {string } from
1125
+ * @param {string } to
1126
+ * @returns {string }
1127
+ */
1052
1128
relative ( from , to ) {
1053
1129
validateString ( from , 'from' ) ;
1054
1130
validateString ( to , 'to' ) ;
@@ -1124,6 +1200,10 @@ const posix = {
1124
1200
return path ;
1125
1201
} ,
1126
1202
1203
+ /**
1204
+ * @param {string } path
1205
+ * @returns {string }
1206
+ */
1127
1207
dirname ( path ) {
1128
1208
validateString ( path , 'path' ) ;
1129
1209
if ( path . length === 0 )
@@ -1150,6 +1230,11 @@ const posix = {
1150
1230
return path . slice ( 0 , end ) ;
1151
1231
} ,
1152
1232
1233
+ /**
1234
+ * @param {string } path
1235
+ * @param {string } [ext]
1236
+ * @returns {string }
1237
+ */
1153
1238
basename ( path , ext ) {
1154
1239
if ( ext !== undefined )
1155
1240
validateString ( ext , 'ext' ) ;
@@ -1225,6 +1310,10 @@ const posix = {
1225
1310
return path . slice ( start , end ) ;
1226
1311
} ,
1227
1312
1313
+ /**
1314
+ * @param {string } path
1315
+ * @returns {string }
1316
+ */
1228
1317
extname ( path ) {
1229
1318
validateString ( path , 'path' ) ;
1230
1319
let startDot = - 1 ;
@@ -1279,6 +1368,16 @@ const posix = {
1279
1368
1280
1369
format : _format . bind ( null , '/' ) ,
1281
1370
1371
+ /**
1372
+ * @param {string } path
1373
+ * @returns {{
1374
+ * dir: string;
1375
+ * root: string;
1376
+ * base: string;
1377
+ * name: string;
1378
+ * ext: string;
1379
+ * }}
1380
+ */
1282
1381
parse ( path ) {
1283
1382
validateString ( path , 'path' ) ;
1284
1383
0 commit comments