Skip to content

Commit b1d3747

Browse files
exoegotargos
exoego
authored andcommitted
lib: convert to arrow function in fs.js
PR-URL: #24604 Reviewed-By: Ouyang Yadong <oyydoibh@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent e96c60e commit b1d3747

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
@@ -144,7 +144,7 @@ function makeCallback(cb) {
144144
throw new ERR_INVALID_CALLBACK();
145145
}
146146

147-
return function(...args) {
147+
return (...args) => {
148148
return Reflect.apply(cb, undefined, args);
149149
};
150150
}
@@ -157,7 +157,7 @@ function makeStatsCallback(cb) {
157157
throw new ERR_INVALID_CALLBACK();
158158
}
159159

160-
return function(err, stats) {
160+
return (err, stats) => {
161161
if (err) return cb(err);
162162
cb(err, getStatsFromBinding(stats));
163163
};
@@ -631,11 +631,11 @@ function truncate(path, len, callback) {
631631

632632
validateInteger(len, 'len');
633633
callback = maybeCallback(callback);
634-
fs.open(path, 'r+', function(er, fd) {
634+
fs.open(path, 'r+', (er, fd) => {
635635
if (er) return callback(er);
636636
const req = new FSReqCallback();
637637
req.oncomplete = function oncomplete(er) {
638-
fs.close(fd, function(er2) {
638+
fs.close(fd, (er2) => {
639639
callback(er || er2);
640640
});
641641
};
@@ -995,15 +995,15 @@ function fchmodSync(fd, mode) {
995995

996996
function lchmod(path, mode, callback) {
997997
callback = maybeCallback(callback);
998-
fs.open(path, O_WRONLY | O_SYMLINK, function(err, fd) {
998+
fs.open(path, O_WRONLY | O_SYMLINK, (err, fd) => {
999999
if (err) {
10001000
callback(err);
10011001
return;
10021002
}
10031003
// Prefer to return the chmod error, if one occurs,
10041004
// but still try to close, and report closing errors if they occur.
1005-
fs.fchmod(fd, mode, function(err) {
1006-
fs.close(fd, function(err2) {
1005+
fs.fchmod(fd, mode, (err) => {
1006+
fs.close(fd, (err2) => {
10071007
callback(err || err2);
10081008
});
10091009
});
@@ -1152,7 +1152,7 @@ function futimesSync(fd, atime, mtime) {
11521152

11531153
function writeAll(fd, isUserFd, buffer, offset, length, position, callback) {
11541154
// write(fd, buffer, offset, length, position, callback)
1155-
fs.write(fd, buffer, offset, length, position, function(writeErr, written) {
1155+
fs.write(fd, buffer, offset, length, position, (writeErr, written) => {
11561156
if (writeErr) {
11571157
if (isUserFd) {
11581158
callback(writeErr);
@@ -1188,7 +1188,7 @@ function writeFile(path, data, options, callback) {
11881188
return;
11891189
}
11901190

1191-
fs.open(path, flag, options.mode, function(openErr, fd) {
1191+
fs.open(path, flag, options.mode, (openErr, fd) => {
11921192
if (openErr) {
11931193
callback(openErr);
11941194
} else {
@@ -1531,7 +1531,7 @@ function realpathSync(p, options) {
15311531
}
15321532

15331533

1534-
realpathSync.native = function(path, options) {
1534+
realpathSync.native = (path, options) => {
15351535
options = getOptions(options, {});
15361536
path = toPathIfFileURL(path);
15371537
validatePath(path);
@@ -1572,7 +1572,7 @@ function realpath(p, options, callback) {
15721572

15731573
// On windows, check that the root exists. On unix there is no need.
15741574
if (isWindows && !knownHard[base]) {
1575-
fs.lstat(base, function(err, stats) {
1575+
fs.lstat(base, (err, stats) => {
15761576
if (err) return callback(err);
15771577
knownHard[base] = true;
15781578
LOOP();
@@ -1636,10 +1636,10 @@ function realpath(p, options, callback) {
16361636
return gotTarget(null, seenLinks[id], base);
16371637
}
16381638
}
1639-
fs.stat(base, function(err) {
1639+
fs.stat(base, (err) => {
16401640
if (err) return callback(err);
16411641

1642-
fs.readlink(base, function(err, target) {
1642+
fs.readlink(base, (err, target) => {
16431643
if (!isWindows) seenLinks[id] = target;
16441644
gotTarget(err, target);
16451645
});
@@ -1660,7 +1660,7 @@ function realpath(p, options, callback) {
16601660

16611661
// On windows, check that the root exists. On unix there is no need.
16621662
if (isWindows && !knownHard[base]) {
1663-
fs.lstat(base, function(err) {
1663+
fs.lstat(base, (err) => {
16641664
if (err) return callback(err);
16651665
knownHard[base] = true;
16661666
LOOP();
@@ -1672,7 +1672,7 @@ function realpath(p, options, callback) {
16721672
}
16731673

16741674

1675-
realpath.native = function(path, options, callback) {
1675+
realpath.native = (path, options, callback) => {
16761676
callback = makeCallback(callback || options);
16771677
options = getOptions(options, {});
16781678
path = toPathIfFileURL(path);

0 commit comments

Comments
 (0)