Skip to content

Commit 7b75cb9

Browse files
TrottMyles Borins
authored and
Myles Borins
committed
test,lib,benchmark: match function names
In most cases, named functions match the variable or property to which they are being assigned. That also seems to be the practice in a series of PRs currently being evaluated that name currently-anonymous functions. This change applies that rule to instances in the code base that don't comply with that practice. This will be enforceable with a lint rule once we upgrade to ESLint 3.8.0. PR-URL: #9113 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
1 parent 88cd4cf commit 7b75cb9

14 files changed

+21
-21
lines changed

benchmark/buffers/buffer-swap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Buffer.prototype.htonl = function htonl() {
4444
return this;
4545
};
4646

47-
Buffer.prototype.htonll = function htonl() {
47+
Buffer.prototype.htonll = function htonll() {
4848
if (this.length % 8 !== 0)
4949
throw new RangeError();
5050
for (var i = 0; i < this.length; i += 8) {

lib/_stream_wrap.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function QueueItem(type, req) {
159159
this.next = this;
160160
}
161161

162-
StreamWrap.prototype._enqueue = function enqueue(type, req) {
162+
StreamWrap.prototype._enqueue = function _enqueue(type, req) {
163163
const item = new QueueItem(type, req);
164164
if (this._list === null) {
165165
this._list = item;
@@ -174,7 +174,7 @@ StreamWrap.prototype._enqueue = function enqueue(type, req) {
174174
return item;
175175
};
176176

177-
StreamWrap.prototype._dequeue = function dequeue(item) {
177+
StreamWrap.prototype._dequeue = function _dequeue(item) {
178178
assert(item instanceof QueueItem);
179179

180180
var next = item.next;

lib/_stream_writable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function WritableState(options, stream) {
117117
this.corkedRequestsFree = new CorkedRequest(this);
118118
}
119119

120-
WritableState.prototype.getBuffer = function writableStateGetBuffer() {
120+
WritableState.prototype.getBuffer = function getBuffer() {
121121
var current = this.bufferedRequest;
122122
var out = [];
123123
while (current) {

lib/_tls_legacy.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ CryptoStream.prototype.init = function init() {
139139
};
140140

141141

142-
CryptoStream.prototype._write = function write(data, encoding, cb) {
142+
CryptoStream.prototype._write = function _write(data, encoding, cb) {
143143
assert(this._pending === null);
144144

145145
// Black-hole data
@@ -220,7 +220,7 @@ CryptoStream.prototype._write = function write(data, encoding, cb) {
220220
};
221221

222222

223-
CryptoStream.prototype._writePending = function writePending() {
223+
CryptoStream.prototype._writePending = function _writePending() {
224224
const data = this._pending;
225225
const encoding = this._pendingEncoding;
226226
const cb = this._pendingCallback;
@@ -232,7 +232,7 @@ CryptoStream.prototype._writePending = function writePending() {
232232
};
233233

234234

235-
CryptoStream.prototype._read = function read(size) {
235+
CryptoStream.prototype._read = function _read(size) {
236236
// XXX: EOF?!
237237
if (!this.pair.ssl) return this.push(null);
238238

lib/_tls_wrap.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ proxiedMethods.forEach(function(name) {
304304
};
305305
});
306306

307-
tls_wrap.TLSWrap.prototype.close = function closeProxy(cb) {
307+
tls_wrap.TLSWrap.prototype.close = function close(cb) {
308308
if (this.owner)
309309
this.owner.ssl = null;
310310

@@ -340,10 +340,10 @@ TLSSocket.prototype._wrapHandle = function(wrap) {
340340
res._secureContext = context;
341341
res.reading = handle.reading;
342342
Object.defineProperty(handle, 'reading', {
343-
get: function readingGetter() {
343+
get: function get() {
344344
return res.reading;
345345
},
346-
set: function readingSetter(value) {
346+
set: function set(value) {
347347
res.reading = value;
348348
}
349349
});

lib/domain.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Domain.prototype._disposed = undefined;
5858

5959

6060
// Called by process._fatalException in case an error was thrown.
61-
Domain.prototype._errorHandler = function errorHandler(er) {
61+
Domain.prototype._errorHandler = function _errorHandler(er) {
6262
var caught = false;
6363

6464
// ignore errors on disposed domains.

lib/fs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ fs.truncate = function(path, len, callback) {
825825
fs.open(path, 'r+', function(er, fd) {
826826
if (er) return callback(er);
827827
var req = new FSReqWrap();
828-
req.oncomplete = function ftruncateCb(er) {
828+
req.oncomplete = function oncomplete(er) {
829829
fs.close(fd, function(er2) {
830830
callback(er || er2);
831831
});

lib/net.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function Socket(options) {
195195
}
196196
util.inherits(Socket, stream.Duplex);
197197

198-
Socket.prototype._unrefTimer = function unrefTimer() {
198+
Socket.prototype._unrefTimer = function _unrefTimer() {
199199
for (var s = this; s !== null; s = s._parent)
200200
timers._unrefActive(s);
201201
};

lib/repl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ exports.start = function(prompt,
664664
return repl;
665665
};
666666

667-
REPLServer.prototype.close = function replClose() {
667+
REPLServer.prototype.close = function close() {
668668
if (this.terminal && this._flushing && !this._closingOnFlush) {
669669
this._closingOnFlush = true;
670670
this.once('flushHistory', () =>

test/parallel/test-child-process-spawn-typeerror.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ assert.throws(function() {
5757
// Argument types for combinatorics
5858
const a = [];
5959
const o = {};
60-
const c = function callback() {};
60+
const c = function c() {};
6161
const s = 'string';
6262
const u = undefined;
6363
const n = null;

test/parallel/test-http-client-readable.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ FakeAgent.prototype.createConnection = function createConnection() {
1515
var s = new Duplex();
1616
var once = false;
1717

18-
s._read = function read() {
18+
s._read = function _read() {
1919
if (once)
2020
return this.push(null);
2121
once = true;
@@ -27,7 +27,7 @@ FakeAgent.prototype.createConnection = function createConnection() {
2727
};
2828

2929
// Blackhole
30-
s._write = function write(data, enc, cb) {
30+
s._write = function _write(data, enc, cb) {
3131
cb();
3232
};
3333

test/parallel/test-repl-persistent-history.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const tests = [
166166
expected: [prompt, replFailedRead, prompt, replDisabled, prompt]
167167
},
168168
{ // Make sure this is always the last test, since we change os.homedir()
169-
before: function mockHomedirFailure() {
169+
before: function before() {
170170
// Mock os.homedir() failure
171171
os.homedir = function() {
172172
throw new Error('os.homedir() failure');

test/parallel/test-repl-tab-complete.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ const testCustomCompleterSyncMode = repl.start({
291291
prompt: '',
292292
input: putIn,
293293
output: putIn,
294-
completer: function completerSyncMode(line) {
294+
completer: function completer(line) {
295295
const hits = customCompletions.filter((c) => {
296296
return c.indexOf(line) === 0;
297297
});
@@ -323,7 +323,7 @@ const testCustomCompleterAsyncMode = repl.start({
323323
prompt: '',
324324
input: putIn,
325325
output: putIn,
326-
completer: function completerAsyncMode(line, callback) {
326+
completer: function completer(line, callback) {
327327
const hits = customCompletions.filter((c) => {
328328
return c.indexOf(line) === 0;
329329
});

test/pummel/test-tls-server-large-request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Mediator() {
2525
}
2626
util.inherits(Mediator, stream.Writable);
2727

28-
Mediator.prototype._write = function write(data, enc, cb) {
28+
Mediator.prototype._write = function _write(data, enc, cb) {
2929
this.buf += data;
3030
setTimeout(cb, 0);
3131

0 commit comments

Comments
 (0)