// Regexp that finds the next partion of a (partial) path
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
-if (isWindows) {
- var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
-} else {
- var nextPartRe = /(.*?)(?:[\/]+|$)/g;
-}
+const nextPartRe = isWindows ?
+ /(.*?)(?:[\/\\]+|$)/g :
+ /(.*?)(?:[\/]+|$)/g;
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
-if (isWindows) {
- var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
-} else {
- var splitRootRe = /^[\/]*/;
-}
+const splitRootRe = isWindows ?
+ /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/ :
+ /^[\/]*/;
fs.realpathSync = function realpathSync(p, cache) {
// make p is absolute