mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
fs: remove unnecessary bind
Don't use Function.prototype.bind where it isn't necessary. Rely on event emitter context instead and on arrow function as class property. PR-URL: https://github.com/nodejs/node/pull/28131 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
committed by
Rich Trott
parent
4547574386
commit
d00d81edd7
@@ -121,7 +121,7 @@ class FileHandle {
|
||||
return writeFile(this, data, options);
|
||||
}
|
||||
|
||||
close() {
|
||||
close = () => {
|
||||
return this[kHandle].close();
|
||||
}
|
||||
}
|
||||
@@ -425,7 +425,7 @@ async function lchmod(path, mode) {
|
||||
throw new ERR_METHOD_NOT_IMPLEMENTED('lchmod()');
|
||||
|
||||
const fd = await open(path, O_WRONLY | O_SYMLINK);
|
||||
return fchmod(fd, mode).finally(fd.close.bind(fd));
|
||||
return fchmod(fd, mode).finally(fd.close);
|
||||
}
|
||||
|
||||
async function lchown(path, uid, gid) {
|
||||
@@ -490,7 +490,7 @@ async function writeFile(path, data, options) {
|
||||
return writeFileHandle(path, data, options);
|
||||
|
||||
const fd = await open(path, flag, options.mode);
|
||||
return writeFileHandle(fd, data, options).finally(fd.close.bind(fd));
|
||||
return writeFileHandle(fd, data, options).finally(fd.close);
|
||||
}
|
||||
|
||||
async function appendFile(path, data, options) {
|
||||
@@ -508,7 +508,7 @@ async function readFile(path, options) {
|
||||
return readFileHandle(path, options);
|
||||
|
||||
const fd = await open(path, flag, 0o666);
|
||||
return readFileHandle(fd, options).finally(fd.close.bind(fd));
|
||||
return readFileHandle(fd, options).finally(fd.close);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -442,7 +442,7 @@ WriteStream.prototype.close = function(cb) {
|
||||
// If we are not autoClosing, we should call
|
||||
// destroy on 'finish'.
|
||||
if (!this.autoClose) {
|
||||
this.on('finish', this.destroy.bind(this));
|
||||
this.on('finish', this.destroy);
|
||||
}
|
||||
|
||||
// We use end() instead of destroy() because of
|
||||
|
||||
Reference in New Issue
Block a user