Skip to content

Commit 1b48c9d

Browse files
exoegoBethGriggs
exoego
authored andcommitted
lib: convert to arrow function in fs.js
PR-URL: #24604 Reviewed-By: Ouyang Yadong <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent 06208c8 commit 1b48c9d

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/fs.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function makeCallback(cb) {
137137
throw new ERR_INVALID_CALLBACK();
138138
}
139139

140-
return function(...args) {
140+
return (...args) => {
141141
return Reflect.apply(cb, undefined, args);
142142
};
143143
}
@@ -150,7 +150,7 @@ function makeStatsCallback(cb) {
150150
throw new ERR_INVALID_CALLBACK();
151151
}
152152

153-
return function(err, stats) {
153+
return (err, stats) => {
154154
if (err) return cb(err);
155155
cb(err, getStatsFromBinding(stats));
156156
};
@@ -608,11 +608,11 @@ function truncate(path, len, callback) {
608608

609609
validateInteger(len, 'len');
610610
callback = maybeCallback(callback);
611-
fs.open(path, 'r+', function(er, fd) {
611+
fs.open(path, 'r+', (er, fd) => {
612612
if (er) return callback(er);
613613
const req = new FSReqWrap();
614614
req.oncomplete = function oncomplete(er) {
615-
fs.close(fd, function(er2) {
615+
fs.close(fd, (er2) => {
616616
callback(er || er2);
617617
});
618618
};
@@ -972,15 +972,15 @@ function fchmodSync(fd, mode) {
972972

973973
function lchmod(path, mode, callback) {
974974
callback = maybeCallback(callback);
975-
fs.open(path, O_WRONLY | O_SYMLINK, function(err, fd) {
975+
fs.open(path, O_WRONLY | O_SYMLINK, (err, fd) => {
976976
if (err) {
977977
callback(err);
978978
return;
979979
}
980980
// Prefer to return the chmod error, if one occurs,
981981
// but still try to close, and report closing errors if they occur.
982-
fs.fchmod(fd, mode, function(err) {
983-
fs.close(fd, function(err2) {
982+
fs.fchmod(fd, mode, (err) => {
983+
fs.close(fd, (err2) => {
984984
callback(err || err2);
985985
});
986986
});
@@ -1129,7 +1129,7 @@ function futimesSync(fd, atime, mtime) {
11291129

11301130
function writeAll(fd, isUserFd, buffer, offset, length, position, callback) {
11311131
// write(fd, buffer, offset, length, position, callback)
1132-
fs.write(fd, buffer, offset, length, position, function(writeErr, written) {
1132+
fs.write(fd, buffer, offset, length, position, (writeErr, written) => {
11331133
if (writeErr) {
11341134
if (isUserFd) {
11351135
callback(writeErr);
@@ -1165,7 +1165,7 @@ function writeFile(path, data, options, callback) {
11651165
return;
11661166
}
11671167

1168-
fs.open(path, flag, options.mode, function(openErr, fd) {
1168+
fs.open(path, flag, options.mode, (openErr, fd) => {
11691169
if (openErr) {
11701170
callback(openErr);
11711171
} else {
@@ -1508,7 +1508,7 @@ function realpathSync(p, options) {
15081508
}
15091509

15101510

1511-
realpathSync.native = function(path, options) {
1511+
realpathSync.native = (path, options) => {
15121512
options = getOptions(options, {});
15131513
path = toPathIfFileURL(path);
15141514
validatePath(path);
@@ -1549,7 +1549,7 @@ function realpath(p, options, callback) {
15491549

15501550
// On windows, check that the root exists. On unix there is no need.
15511551
if (isWindows && !knownHard[base]) {
1552-
fs.lstat(base, function(err, stats) {
1552+
fs.lstat(base, (err, stats) => {
15531553
if (err) return callback(err);
15541554
knownHard[base] = true;
15551555
LOOP();
@@ -1613,10 +1613,10 @@ function realpath(p, options, callback) {
16131613
return gotTarget(null, seenLinks[id], base);
16141614
}
16151615
}
1616-
fs.stat(base, function(err) {
1616+
fs.stat(base, (err) => {
16171617
if (err) return callback(err);
16181618

1619-
fs.readlink(base, function(err, target) {
1619+
fs.readlink(base, (err, target) => {
16201620
if (!isWindows) seenLinks[id] = target;
16211621
gotTarget(err, target);
16221622
});
@@ -1637,7 +1637,7 @@ function realpath(p, options, callback) {
16371637

16381638
// On windows, check that the root exists. On unix there is no need.
16391639
if (isWindows && !knownHard[base]) {
1640-
fs.lstat(base, function(err) {
1640+
fs.lstat(base, (err) => {
16411641
if (err) return callback(err);
16421642
knownHard[base] = true;
16431643
LOOP();
@@ -1649,7 +1649,7 @@ function realpath(p, options, callback) {
16491649
}
16501650

16511651

1652-
realpath.native = function(path, options, callback) {
1652+
realpath.native = (path, options, callback) => {
16531653
callback = makeCallback(callback || options);
16541654
options = getOptions(options, {});
16551655
path = toPathIfFileURL(path);

0 commit comments

Comments
 (0)