Skip to content

Commit 5b75572

Browse files
dayninMylesBorins
authored andcommitted
fs: replace magic numbers by named constants
PR-URL: #18757 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]>
1 parent 2c7de9d commit 5b75572

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/fs.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ const {
4646
assertEncoding,
4747
stringToFlags
4848
} = internalFS;
49+
const {
50+
CHAR_FORWARD_SLASH,
51+
CHAR_BACKWARD_SLASH,
52+
} = require('internal/constants');
4953

5054
Object.defineProperty(exports, 'constants', {
5155
configurable: false,
@@ -1569,7 +1573,7 @@ if (isWindows) {
15691573
} else {
15701574
splitRoot = function splitRoot(str) {
15711575
for (var i = 0; i < str.length; ++i) {
1572-
if (str.charCodeAt(i) !== 47/*'/'*/)
1576+
if (str.charCodeAt(i) !== CHAR_FORWARD_SLASH)
15731577
return str.slice(0, i);
15741578
}
15751579
return str;
@@ -1593,7 +1597,9 @@ if (isWindows) {
15931597
nextPart = function nextPart(p, i) {
15941598
for (; i < p.length; ++i) {
15951599
const ch = p.charCodeAt(i);
1596-
if (ch === 92/*'\'*/ || ch === 47/*'/'*/)
1600+
1601+
// Check for a separator character
1602+
if (ch === CHAR_BACKWARD_SLASH || ch === CHAR_FORWARD_SLASH)
15971603
return i;
15981604
}
15991605
return -1;

0 commit comments

Comments
 (0)