Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: remove unnecessary bind #28131

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/_http_client.js
Expand Up @@ -327,7 +327,7 @@ ClientRequest.prototype._implicitHeader = function _implicitHeader() {

ClientRequest.prototype.abort = function abort() {
if (!this.aborted) {
process.nextTick(emitAbortNT.bind(this));
process.nextTick(emitAbortNT, this);
}
this.aborted = true;

Expand All @@ -345,8 +345,8 @@ ClientRequest.prototype.abort = function abort() {
};


function emitAbortNT() {
this.emit('abort');
function emitAbortNT(req) {
req.emit('abort');
}

function ondrain() {
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/cluster/child.js
Expand Up @@ -118,8 +118,8 @@ function shared(message, handle, indexesKey, cb) {
send({ act: 'close', key });
handles.delete(key);
indexes.delete(indexesKey);
return close.apply(this, arguments);
}.bind(handle);
return close.apply(handle, arguments);
};
assert(handles.has(key) === false);
handles.set(key, handle);
cb(message.errno, handle);
Expand Down
8 changes: 4 additions & 4 deletions lib/internal/fs/promises.js
Expand Up @@ -121,7 +121,7 @@ class FileHandle {
return writeFile(this, data, options);
}

close() {
close = () => {
return this[kHandle].close();
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/fs/streams.js
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/internal/http2/core.js
Expand Up @@ -2152,12 +2152,16 @@ class Http2Stream extends Duplex {
// By using setImmediate we allow pushStreams to make it through
// before the stream is officially closed. This prevents a bug
// in most browsers where those pushStreams would be rejected.
setImmediate(this.close.bind(this));
setImmediate(callStreamClose, this);
}
}
}
}

function callStreamClose(stream) {
stream.close();
}

function processHeaders(oldHeaders) {
assertIsObject(oldHeaders, 'headers');
const headers = ObjectCreate(null);
Expand Down
17 changes: 10 additions & 7 deletions lib/perf_hooks.js
Expand Up @@ -463,11 +463,14 @@ function getObserversList(type) {
return list;
}

function doNotify() {
this[kQueued] = false;
this.runInAsyncScope(this[kCallback], this, this[kBuffer], this);
this[kBuffer][kEntries] = [];
L.init(this[kBuffer][kEntries]);
function doNotify(observer) {
observer[kQueued] = false;
observer.runInAsyncScope(observer[kCallback],
observer,
observer[kBuffer],
observer);
observer[kBuffer][kEntries] = [];
L.init(observer[kBuffer][kEntries]);
}

// Set up the callback used to receive PerformanceObserver notifications
Expand All @@ -493,11 +496,11 @@ function observersCallback(entry) {
observer[kQueued] = true;
// Use setImmediate instead of nextTick to give more time
// for multiple entries to collect.
setImmediate(doNotify.bind(observer));
setImmediate(doNotify, observer);
}
} else {
// If not buffering, notify immediately
doNotify.call(observer);
doNotify(observer);
}
current = current._idlePrev;
}
Expand Down