0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

fs: replace magic numbers by named constants

PR-URL: https://github.com/nodejs/node/pull/18757
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
This commit is contained in:
Sergey Golovin 2018-02-13 14:49:53 +03:00 committed by Matheus Marchini
parent 759a083d44
commit d8d84eee18

View File

@ -46,6 +46,10 @@ const {
assertEncoding,
stringToFlags
} = internalFS;
const {
CHAR_FORWARD_SLASH,
CHAR_BACKWARD_SLASH,
} = require('internal/constants');
Object.defineProperty(exports, 'constants', {
configurable: false,
@ -1796,7 +1800,7 @@ if (isWindows) {
} else {
splitRoot = function splitRoot(str) {
for (var i = 0; i < str.length; ++i) {
if (str.charCodeAt(i) !== 47/*'/'*/)
if (str.charCodeAt(i) !== CHAR_FORWARD_SLASH)
return str.slice(0, i);
}
return str;
@ -1820,7 +1824,9 @@ if (isWindows) {
nextPart = function nextPart(p, i) {
for (; i < p.length; ++i) {
const ch = p.charCodeAt(i);
if (ch === 92/*'\'*/ || ch === 47/*'/'*/)
// Check for a separator character
if (ch === CHAR_BACKWARD_SLASH || ch === CHAR_FORWARD_SLASH)
return i;
}
return -1;