| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,6 +127,17 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) { | |||
| 127 | 127 | return res; | |
| 128 | 128 | } | |
| 129 | 129 | ||
| 130 | + /** | ||
| 131 | + * @param {string} sep | ||
| 132 | + * @param {{ | ||
| 133 | + * dir?: string; | ||
| 134 | + * root?: string; | ||
| 135 | + * base?: string; | ||
| 136 | + * name?: string; | ||
| 137 | + * ext?: string; | ||
| 138 | + * }} pathObject | ||
| 139 | + * @returns {string} | ||
| 140 | + */ | ||
| 130 | 141 | function _format(sep, pathObject) { | |
| 131 | 142 | validateObject(pathObject, 'pathObject'); | |
| 132 | 143 | const dir = pathObject.dir || pathObject.root; | |
@@ -139,7 +150,11 @@ function _format(sep, pathObject) { | |||
| 139 | 150 | } | |
| 140 | 151 | ||
| 141 | 152 | const win32 = { | |
| 142 | - // path.resolve([from ...], to) | ||
| 153 | + /** | ||
| 154 | + * path.resolve([from ...], to) | ||
| 155 | + * @param {...string} args | ||
| 156 | + * @returns {string} | ||
| 157 | + */ | ||
| 143 | 158 | resolve(...args) { | |
| 144 | 159 | let resolvedDevice = ''; | |
| 145 | 160 | let resolvedTail = ''; | |
@@ -282,6 +297,10 @@ const win32 = { | |||
| 282 | 297 | `${resolvedDevice}${resolvedTail}` || '.'; | |
| 283 | 298 | }, | |
| 284 | 299 | ||
| 300 | + /** | ||
| 301 | + * @param {string} path | ||
| 302 | + * @returns {string} | ||
| 303 | + */ | ||
| 285 | 304 | normalize(path) { | |
| 286 | 305 | validateString(path, 'path'); | |
| 287 | 306 | const len = path.length; | |
@@ -376,6 +395,10 @@ const win32 = { | |||
| 376 | 395 | return isAbsolute ? `${device}\\${tail}` : `${device}${tail}`; | |
| 377 | 396 | }, | |
| 378 | 397 | ||
| 398 | + /** | ||
| 399 | + * @param {string} path | ||
| 400 | + * @returns {boolean} | ||
| 401 | + */ | ||
| 379 | 402 | isAbsolute(path) { | |
| 380 | 403 | validateString(path, 'path'); | |
| 381 | 404 | const len = path.length; | |
@@ -391,6 +414,10 @@ const win32 = { | |||
| 391 | 414 | isPathSeparator(StringPrototypeCharCodeAt(path, 2))); | |
| 392 | 415 | }, | |
| 393 | 416 | ||
| 417 | + /** | ||
| 418 | + * @param {...string} args | ||
| 419 | + * @returns {string} | ||
| 420 | + */ | ||
| 394 | 421 | join(...args) { | |
| 395 | 422 | if (args.length === 0) | |
| 396 | 423 | return '.'; | |
@@ -457,10 +484,15 @@ const win32 = { | |||
| 457 | 484 | return win32.normalize(joined); | |
| 458 | 485 | }, | |
| 459 | 486 | ||
| 460 | - // It will solve the relative path from `from` to `to`, for instance: | ||
| 461 | - // from = 'C:\\orandea\\test\\aaa' | ||
| 462 | - // to = 'C:\\orandea\\impl\\bbb' | ||
| 463 | - // The output of the function should be: '..\\..\\impl\\bbb' | ||
| 487 | + /** | ||
| 488 | + * It will solve the relative path from `from` to `to`, for instancee | ||
| 489 | + * from = 'C:\\orandea\\test\\aaa' | ||
| 490 | + * to = 'C:\\orandea\\impl\\bbb' | ||
| 491 | + * The output of the function should be: '..\\..\\impl\\bbb' | ||
| 492 | + * @param {string} from | ||
| 493 | + * @param {string} to | ||
| 494 | + * @returns {string} | ||
| 495 | + */ | ||
| 464 | 496 | relative(from, to) { | |
| 465 | 497 | validateString(from, 'from'); | |
| 466 | 498 | validateString(to, 'to'); | |
@@ -618,6 +650,10 @@ const win32 = { | |||
| 618 | 650 | return path; | |
| 619 | 651 | }, | |
| 620 | 652 | ||
| 653 | + /** | ||
| 654 | + * @param {string} path | ||
| 655 | + * @returns {string} | ||
| 656 | + */ | ||
| 621 | 657 | dirname(path) { | |
| 622 | 658 | validateString(path, 'path'); | |
| 623 | 659 | const len = path.length; | |
@@ -709,6 +745,11 @@ const win32 = { | |||
| 709 | 745 | return StringPrototypeSlice(path, 0, end); | |
| 710 | 746 | }, | |
| 711 | 747 | ||
| 748 | + /** | ||
| 749 | + * @param {string} path | ||
| 750 | + * @param {string} [ext] | ||
| 751 | + * @returns {string} | ||
| 752 | + */ | ||
| 712 | 753 | basename(path, ext) { | |
| 713 | 754 | if (ext !== undefined) | |
| 714 | 755 | validateString(ext, 'ext'); | |
@@ -792,6 +833,10 @@ const win32 = { | |||
| 792 | 833 | return StringPrototypeSlice(path, start, end); | |
| 793 | 834 | }, | |
| 794 | 835 | ||
| 836 | + /** | ||
| 837 | + * @param {string} path | ||
| 838 | + * @returns {string} | ||
| 839 | + */ | ||
| 795 | 840 | extname(path) { | |
| 796 | 841 | validateString(path, 'path'); | |
| 797 | 842 | let start = 0; | |
@@ -858,6 +903,16 @@ const win32 = { | |||
| 858 | 903 | ||
| 859 | 904 | format: FunctionPrototypeBind(_format, null, '\\'), | |
| 860 | 905 | ||
| 906 | + /** | ||
| 907 | + * @param {string} path | ||
| 908 | + * @returns {{ | ||
| 909 | + * dir: string; | ||
| 910 | + * root: string; | ||
| 911 | + * base: string; | ||
| 912 | + * name: string; | ||
| 913 | + * ext: string; | ||
| 914 | + * }} | ||
| 915 | + */ | ||
| 861 | 916 | parse(path) { | |
| 862 | 917 | validateString(path, 'path'); | |
| 863 | 918 | ||
@@ -1032,7 +1087,11 @@ const posixCwd = (() => { | |||
| 1032 | 1087 | })(); | |
| 1033 | 1088 | ||
| 1034 | 1089 | const posix = { | |
| 1035 | - // path.resolve([from ...], to) | ||
| 1090 | + /** | ||
| 1091 | + * path.resolve([from ...], to) | ||
| 1092 | + * @param {...string} args | ||
| 1093 | + * @returns {string} | ||
| 1094 | + */ | ||
| 1036 | 1095 | resolve(...args) { | |
| 1037 | 1096 | let resolvedPath = ''; | |
| 1038 | 1097 | let resolvedAbsolute = false; | |
@@ -1065,6 +1124,10 @@ const posix = { | |||
| 1065 | 1124 | return resolvedPath.length > 0 ? resolvedPath : '.'; | |
| 1066 | 1125 | }, | |
| 1067 | 1126 | ||
| 1127 | + /** | ||
| 1128 | + * @param {string} path | ||
| 1129 | + * @returns {string} | ||
| 1130 | + */ | ||
| 1068 | 1131 | normalize(path) { | |
| 1069 | 1132 | validateString(path, 'path'); | |
| 1070 | 1133 | ||
@@ -1090,12 +1153,20 @@ const posix = { | |||
| 1090 | 1153 | return isAbsolute ? `/${path}` : path; | |
| 1091 | 1154 | }, | |
| 1092 | 1155 | ||
| 1156 | + /** | ||
| 1157 | + * @param {string} path | ||
| 1158 | + * @returns {boolean} | ||
| 1159 | + */ | ||
| 1093 | 1160 | isAbsolute(path) { | |
| 1094 | 1161 | validateString(path, 'path'); | |
| 1095 | 1162 | return path.length > 0 && | |
| 1096 | 1163 | StringPrototypeCharCodeAt(path, 0) === CHAR_FORWARD_SLASH; | |
| 1097 | 1164 | }, | |
| 1098 | 1165 | ||
| 1166 | + /** | ||
| 1167 | + * @param {...string} args | ||
| 1168 | + * @returns {string} | ||
| 1169 | + */ | ||
| 1099 | 1170 | join(...args) { | |
| 1100 | 1171 | if (args.length === 0) | |
| 1101 | 1172 | return '.'; | |
@@ -1115,6 +1186,11 @@ const posix = { | |||
| 1115 | 1186 | return posix.normalize(joined); | |
| 1116 | 1187 | }, | |
| 1117 | 1188 | ||
| 1189 | + /** | ||
| 1190 | + * @param {string} from | ||
| 1191 | + * @param {string} to | ||
| 1192 | + * @returns {string} | ||
| 1193 | + */ | ||
| 1118 | 1194 | relative(from, to) { | |
| 1119 | 1195 | validateString(from, 'from'); | |
| 1120 | 1196 | validateString(to, 'to'); | |
@@ -1196,6 +1272,10 @@ const posix = { | |||
| 1196 | 1272 | return path; | |
| 1197 | 1273 | }, | |
| 1198 | 1274 | ||
| 1275 | + /** | ||
| 1276 | + * @param {string} path | ||
| 1277 | + * @returns {string} | ||
| 1278 | + */ | ||
| 1199 | 1279 | dirname(path) { | |
| 1200 | 1280 | validateString(path, 'path'); | |
| 1201 | 1281 | if (path.length === 0) | |
@@ -1222,6 +1302,11 @@ const posix = { | |||
| 1222 | 1302 | return StringPrototypeSlice(path, 0, end); | |
| 1223 | 1303 | }, | |
| 1224 | 1304 | ||
| 1305 | + /** | ||
| 1306 | + * @param {string} path | ||
| 1307 | + * @param {string} [ext] | ||
| 1308 | + * @returns {string} | ||
| 1309 | + */ | ||
| 1225 | 1310 | basename(path, ext) { | |
| 1226 | 1311 | if (ext !== undefined) | |
| 1227 | 1312 | validateString(ext, 'ext'); | |
@@ -1297,6 +1382,10 @@ const posix = { | |||
| 1297 | 1382 | return StringPrototypeSlice(path, start, end); | |
| 1298 | 1383 | }, | |
| 1299 | 1384 | ||
| 1385 | + /** | ||
| 1386 | + * @param {string} path | ||
| 1387 | + * @returns {string} | ||
| 1388 | + */ | ||
| 1300 | 1389 | extname(path) { | |
| 1301 | 1390 | validateString(path, 'path'); | |
| 1302 | 1391 | let startDot = -1; | |
@@ -1351,6 +1440,16 @@ const posix = { | |||
| 1351 | 1440 | ||
| 1352 | 1441 | format: FunctionPrototypeBind(_format, null, '/'), | |
| 1353 | 1442 | ||
| 1443 | + /** | ||
| 1444 | + * @param {string} path | ||
| 1445 | + * @returns {{ | ||
| 1446 | + * dir: string; | ||
| 1447 | + * root: string; | ||
| 1448 | + * base: string; | ||
| 1449 | + * name: string; | ||
| 1450 | + * ext: string; | ||
| 1451 | + * }} | ||
| 1452 | + */ | ||
| 1354 | 1453 | parse(path) { | |
| 1355 | 1454 | validateString(path, 'path'); | |
| 1356 | 1455 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments