-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
path: refactor to reduce duplicated codes #18594
Conversation
There are many duplicated codes in methods such as `normalizeString`, `format`, `extname` and `basename`. This change is to reduce them.
6e62251
to
c68ada1
Compare
var res = ''; | ||
var lastSegmentLength = 0; | ||
var lastSlash = -1; | ||
var dots = 0; | ||
var code; | ||
var slashChar = win32 ? '\\' : '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use const
here
@@ -178,6 +120,160 @@ function _format(sep, pathObject) { | |||
return dir + sep + base; | |||
} | |||
|
|||
function _extname(path, win32) { | |||
assertPath(path); | |||
var start = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use let/const instead of var in places where in possible
This PR will be rebased after another PR (#18654) lands. |
This needs a rebase. |
This PR is out of date and hard to rebase. I'll open another PR. |
There are many duplicated codes in methods such as
normalizeString
,format
,extname
andbasename
.This change is to reduce them.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
path