Skip to content

Commit 2f2a8aa

Browse files
pezetargos
authored andcommitted
path: replace var with let in lib/path.js
PR-URL: #30260 Refs: nodejs/code-and-learn#97 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
1 parent 75cb026 commit 2f2a8aa

1 file changed

Lines changed: 50 additions & 52 deletions

File tree

‎lib/path.js‎

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
5555
letlastSlash=-1;
5656
letdots=0;
5757
letcode=0;
58-
for(vari=0;i<=path.length;++i){
58+
for(leti=0;i<=path.length;++i){
5959
if(i<path.length)
6060
code=path.charCodeAt(i);
6161
elseif(isPathSeparator(code))
@@ -132,7 +132,7 @@ const win32 = {
132132
letresolvedTail='';
133133
letresolvedAbsolute=false;
134134

135-
for(vari=args.length-1;i>=-1;i--){
135+
for(leti=args.length-1;i>=-1;i--){
136136
letpath;
137137
if(i>=0){
138138
path=args[i];
@@ -370,7 +370,7 @@ const win32 = {
370370

371371
letjoined;
372372
letfirstPart;
373-
for(vari=0;i<args.length;++i){
373+
for(leti=0;i<args.length;++i){
374374
constarg=args[i];
375375
validateString(arg,'path');
376376
if(arg.length>0){
@@ -644,7 +644,7 @@ const win32 = {
644644

645645
letend=-1;
646646
letmatchedSlash=true;
647-
for(vari=len-1;i>=offset;--i){
647+
for(leti=len-1;i>=offset;--i){
648648
if(isPathSeparator(path.charCodeAt(i))){
649649
if(!matchedSlash){
650650
end=i;
@@ -669,10 +669,9 @@ const win32 = {
669669
if(ext!==undefined)
670670
validateString(ext,'ext');
671671
validateString(path,'path');
672-
varstart=0;
673-
varend=-1;
674-
varmatchedSlash=true;
675-
vari;
672+
letstart=0;
673+
letend=-1;
674+
letmatchedSlash=true;
676675

677676
// Check for a drive letter prefix so as not to mistake the following
678677
// path separator as an extra separator at the end of the path that can be
@@ -686,9 +685,9 @@ const win32 = {
686685
if(ext!==undefined&&ext.length>0&&ext.length<=path.length){
687686
if(ext===path)
688687
return'';
689-
varextIdx=ext.length-1;
690-
varfirstNonSlashEnd=-1;
691-
for(i=path.length-1;i>=start;--i){
688+
letextIdx=ext.length-1;
689+
letfirstNonSlashEnd=-1;
690+
for(leti=path.length-1;i>=start;--i){
692691
constcode=path.charCodeAt(i);
693692
if(isPathSeparator(code)){
694693
// If we reached a path separator that was not part of a set of path
@@ -728,7 +727,7 @@ const win32 = {
728727
end=path.length;
729728
returnpath.slice(start,end);
730729
}
731-
for(i=path.length-1;i>=start;--i){
730+
for(leti=path.length-1;i>=start;--i){
732731
if(isPathSeparator(path.charCodeAt(i))){
733732
// If we reached a path separator that was not part of a set of path
734733
// separators at the end of the string, stop now
@@ -751,14 +750,14 @@ const win32 = {
751750

752751
extname(path){
753752
validateString(path,'path');
754-
varstart=0;
755-
varstartDot=-1;
756-
varstartPart=0;
757-
varend=-1;
758-
varmatchedSlash=true;
753+
letstart=0;
754+
letstartDot=-1;
755+
letstartPart=0;
756+
letend=-1;
757+
letmatchedSlash=true;
759758
// Track the state of characters (if any) we see before our first dot and
760759
// after any path separator we find
761-
varpreDotState=0;
760+
letpreDotState=0;
762761

763762
// Check for a drive letter prefix so as not to mistake the following
764763
// path separator as an extra separator at the end of the path that can be
@@ -770,7 +769,7 @@ const win32 = {
770769
start=startPart=2;
771770
}
772771

773-
for(vari=path.length-1;i>=start;--i){
772+
for(leti=path.length-1;i>=start;--i){
774773
constcode=path.charCodeAt(i);
775774
if(isPathSeparator(code)){
776775
// If we reached a path separator that was not part of a set of path
@@ -823,7 +822,7 @@ const win32 = {
823822
returnret;
824823

825824
constlen=path.length;
826-
varrootEnd=0;
825+
letrootEnd=0;
827826
letcode=path.charCodeAt(0);
828827

829828
if(len===1){
@@ -895,15 +894,15 @@ const win32 = {
895894
if(rootEnd>0)
896895
ret.root=path.slice(0,rootEnd);
897896

898-
varstartDot=-1;
899-
varstartPart=rootEnd;
900-
varend=-1;
901-
varmatchedSlash=true;
902-
vari=path.length-1;
897+
letstartDot=-1;
898+
letstartPart=rootEnd;
899+
letend=-1;
900+
letmatchedSlash=true;
901+
leti=path.length-1;
903902

904903
// Track the state of characters (if any) we see before our first dot and
905904
// after any path separator we find
906-
varpreDotState=0;
905+
letpreDotState=0;
907906

908907
// Get non-dir info
909908
for(;i>=rootEnd;--i){
@@ -975,7 +974,7 @@ const posix = {
975974
letresolvedPath='';
976975
letresolvedAbsolute=false;
977976

978-
for(vari=args.length-1;i>=-1&&!resolvedAbsolute;i--){
977+
for(leti=args.length-1;i>=-1&&!resolvedAbsolute;i--){
979978
constpath=i>=0 ? args[i] : process.cwd();
980979

981980
validateString(path,'path');
@@ -1035,7 +1034,7 @@ const posix = {
10351034
if(args.length===0)
10361035
return'.';
10371036
letjoined;
1038-
for(vari=0;i<args.length;++i){
1037+
for(leti=0;i<args.length;++i){
10391038
constarg=args[i];
10401039
validateString(arg,'path');
10411040
if(arg.length>0){
@@ -1130,9 +1129,9 @@ const posix = {
11301129
if(path.length===0)
11311130
return'.';
11321131
consthasRoot=path.charCodeAt(0)===CHAR_FORWARD_SLASH;
1133-
varend=-1;
1134-
varmatchedSlash=true;
1135-
for(vari=path.length-1;i>=1;--i){
1132+
letend=-1;
1133+
letmatchedSlash=true;
1134+
for(leti=path.length-1;i>=1;--i){
11361135
if(path.charCodeAt(i)===CHAR_FORWARD_SLASH){
11371136
if(!matchedSlash){
11381137
end=i;
@@ -1156,17 +1155,16 @@ const posix = {
11561155
validateString(ext,'ext');
11571156
validateString(path,'path');
11581157

1159-
varstart=0;
1160-
varend=-1;
1161-
varmatchedSlash=true;
1162-
vari;
1158+
letstart=0;
1159+
letend=-1;
1160+
letmatchedSlash=true;
11631161

11641162
if(ext!==undefined&&ext.length>0&&ext.length<=path.length){
11651163
if(ext===path)
11661164
return'';
1167-
varextIdx=ext.length-1;
1168-
varfirstNonSlashEnd=-1;
1169-
for(i=path.length-1;i>=0;--i){
1165+
letextIdx=ext.length-1;
1166+
letfirstNonSlashEnd=-1;
1167+
for(leti=path.length-1;i>=0;--i){
11701168
constcode=path.charCodeAt(i);
11711169
if(code===CHAR_FORWARD_SLASH){
11721170
// If we reached a path separator that was not part of a set of path
@@ -1206,7 +1204,7 @@ const posix = {
12061204
end=path.length;
12071205
returnpath.slice(start,end);
12081206
}
1209-
for(i=path.length-1;i>=0;--i){
1207+
for(leti=path.length-1;i>=0;--i){
12101208
if(path.charCodeAt(i)===CHAR_FORWARD_SLASH){
12111209
// If we reached a path separator that was not part of a set of path
12121210
// separators at the end of the string, stop now
@@ -1229,14 +1227,14 @@ const posix = {
12291227

12301228
extname(path){
12311229
validateString(path,'path');
1232-
varstartDot=-1;
1233-
varstartPart=0;
1234-
varend=-1;
1235-
varmatchedSlash=true;
1230+
letstartDot=-1;
1231+
letstartPart=0;
1232+
letend=-1;
1233+
letmatchedSlash=true;
12361234
// Track the state of characters (if any) we see before our first dot and
12371235
// after any path separator we find
1238-
varpreDotState=0;
1239-
for(vari=path.length-1;i>=0;--i){
1236+
letpreDotState=0;
1237+
for(leti=path.length-1;i>=0;--i){
12401238
constcode=path.charCodeAt(i);
12411239
if(code===CHAR_FORWARD_SLASH){
12421240
// If we reached a path separator that was not part of a set of path
@@ -1288,22 +1286,22 @@ const posix = {
12881286
if(path.length===0)
12891287
returnret;
12901288
constisAbsolute=path.charCodeAt(0)===CHAR_FORWARD_SLASH;
1291-
varstart;
1289+
letstart;
12921290
if(isAbsolute){
12931291
ret.root='/';
12941292
start=1;
12951293
}else{
12961294
start=0;
12971295
}
1298-
varstartDot=-1;
1299-
varstartPart=0;
1300-
varend=-1;
1301-
varmatchedSlash=true;
1302-
vari=path.length-1;
1296+
letstartDot=-1;
1297+
letstartPart=0;
1298+
letend=-1;
1299+
letmatchedSlash=true;
1300+
leti=path.length-1;
13031301

13041302
// Track the state of characters (if any) we see before our first dot and
13051303
// after any path separator we find
1306-
varpreDotState=0;
1304+
letpreDotState=0;
13071305

13081306
// Get non-dir info
13091307
for(;i>=start;--i){

0 commit comments

Comments
 (0)