Browse Source

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: https://github.com/nodejs/node/pull/9113
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
v6.x
Rich Trott 8 years ago
committed by Myles Borins
parent
commit
7b75cb9e5a
  1. 2
      benchmark/buffers/buffer-swap.js
  2. 4
      lib/_stream_wrap.js
  3. 2
      lib/_stream_writable.js
  4. 6
      lib/_tls_legacy.js
  5. 6
      lib/_tls_wrap.js
  6. 2
      lib/domain.js
  7. 2
      lib/fs.js
  8. 2
      lib/net.js
  9. 2
      lib/repl.js
  10. 2
      test/parallel/test-child-process-spawn-typeerror.js
  11. 4
      test/parallel/test-http-client-readable.js
  12. 2
      test/parallel/test-repl-persistent-history.js
  13. 4
      test/parallel/test-repl-tab-complete.js
  14. 2
      test/pummel/test-tls-server-large-request.js

2
benchmark/buffers/buffer-swap.js

@ -44,7 +44,7 @@ Buffer.prototype.htonl = function htonl() {
return this; return this;
}; };
Buffer.prototype.htonll = function htonl() { Buffer.prototype.htonll = function htonll() {
if (this.length % 8 !== 0) if (this.length % 8 !== 0)
throw new RangeError(); throw new RangeError();
for (var i = 0; i < this.length; i += 8) { for (var i = 0; i < this.length; i += 8) {

4
lib/_stream_wrap.js

@ -159,7 +159,7 @@ function QueueItem(type, req) {
this.next = this; this.next = this;
} }
StreamWrap.prototype._enqueue = function enqueue(type, req) { StreamWrap.prototype._enqueue = function _enqueue(type, req) {
const item = new QueueItem(type, req); const item = new QueueItem(type, req);
if (this._list === null) { if (this._list === null) {
this._list = item; this._list = item;
@ -174,7 +174,7 @@ StreamWrap.prototype._enqueue = function enqueue(type, req) {
return item; return item;
}; };
StreamWrap.prototype._dequeue = function dequeue(item) { StreamWrap.prototype._dequeue = function _dequeue(item) {
assert(item instanceof QueueItem); assert(item instanceof QueueItem);
var next = item.next; var next = item.next;

2
lib/_stream_writable.js

@ -117,7 +117,7 @@ function WritableState(options, stream) {
this.corkedRequestsFree = new CorkedRequest(this); this.corkedRequestsFree = new CorkedRequest(this);
} }
WritableState.prototype.getBuffer = function writableStateGetBuffer() { WritableState.prototype.getBuffer = function getBuffer() {
var current = this.bufferedRequest; var current = this.bufferedRequest;
var out = []; var out = [];
while (current) { while (current) {

6
lib/_tls_legacy.js

@ -139,7 +139,7 @@ CryptoStream.prototype.init = function init() {
}; };
CryptoStream.prototype._write = function write(data, encoding, cb) { CryptoStream.prototype._write = function _write(data, encoding, cb) {
assert(this._pending === null); assert(this._pending === null);
// Black-hole data // Black-hole data
@ -220,7 +220,7 @@ CryptoStream.prototype._write = function write(data, encoding, cb) {
}; };
CryptoStream.prototype._writePending = function writePending() { CryptoStream.prototype._writePending = function _writePending() {
const data = this._pending; const data = this._pending;
const encoding = this._pendingEncoding; const encoding = this._pendingEncoding;
const cb = this._pendingCallback; const cb = this._pendingCallback;
@ -232,7 +232,7 @@ CryptoStream.prototype._writePending = function writePending() {
}; };
CryptoStream.prototype._read = function read(size) { CryptoStream.prototype._read = function _read(size) {
// XXX: EOF?! // XXX: EOF?!
if (!this.pair.ssl) return this.push(null); if (!this.pair.ssl) return this.push(null);

6
lib/_tls_wrap.js

@ -304,7 +304,7 @@ proxiedMethods.forEach(function(name) {
}; };
}); });
tls_wrap.TLSWrap.prototype.close = function closeProxy(cb) { tls_wrap.TLSWrap.prototype.close = function close(cb) {
if (this.owner) if (this.owner)
this.owner.ssl = null; this.owner.ssl = null;
@ -340,10 +340,10 @@ TLSSocket.prototype._wrapHandle = function(wrap) {
res._secureContext = context; res._secureContext = context;
res.reading = handle.reading; res.reading = handle.reading;
Object.defineProperty(handle, 'reading', { Object.defineProperty(handle, 'reading', {
get: function readingGetter() { get: function get() {
return res.reading; return res.reading;
}, },
set: function readingSetter(value) { set: function set(value) {
res.reading = value; res.reading = value;
} }
}); });

2
lib/domain.js

@ -58,7 +58,7 @@ Domain.prototype._disposed = undefined;
// Called by process._fatalException in case an error was thrown. // Called by process._fatalException in case an error was thrown.
Domain.prototype._errorHandler = function errorHandler(er) { Domain.prototype._errorHandler = function _errorHandler(er) {
var caught = false; var caught = false;
// ignore errors on disposed domains. // ignore errors on disposed domains.

2
lib/fs.js

@ -825,7 +825,7 @@ fs.truncate = function(path, len, callback) {
fs.open(path, 'r+', function(er, fd) { fs.open(path, 'r+', function(er, fd) {
if (er) return callback(er); if (er) return callback(er);
var req = new FSReqWrap(); var req = new FSReqWrap();
req.oncomplete = function ftruncateCb(er) { req.oncomplete = function oncomplete(er) {
fs.close(fd, function(er2) { fs.close(fd, function(er2) {
callback(er || er2); callback(er || er2);
}); });

2
lib/net.js

@ -195,7 +195,7 @@ function Socket(options) {
} }
util.inherits(Socket, stream.Duplex); util.inherits(Socket, stream.Duplex);
Socket.prototype._unrefTimer = function unrefTimer() { Socket.prototype._unrefTimer = function _unrefTimer() {
for (var s = this; s !== null; s = s._parent) for (var s = this; s !== null; s = s._parent)
timers._unrefActive(s); timers._unrefActive(s);
}; };

2
lib/repl.js

@ -664,7 +664,7 @@ exports.start = function(prompt,
return repl; return repl;
}; };
REPLServer.prototype.close = function replClose() { REPLServer.prototype.close = function close() {
if (this.terminal && this._flushing && !this._closingOnFlush) { if (this.terminal && this._flushing && !this._closingOnFlush) {
this._closingOnFlush = true; this._closingOnFlush = true;
this.once('flushHistory', () => this.once('flushHistory', () =>

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

@ -57,7 +57,7 @@ assert.throws(function() {
// Argument types for combinatorics // Argument types for combinatorics
const a = []; const a = [];
const o = {}; const o = {};
const c = function callback() {}; const c = function c() {};
const s = 'string'; const s = 'string';
const u = undefined; const u = undefined;
const n = null; const n = null;

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

@ -15,7 +15,7 @@ FakeAgent.prototype.createConnection = function createConnection() {
var s = new Duplex(); var s = new Duplex();
var once = false; var once = false;
s._read = function read() { s._read = function _read() {
if (once) if (once)
return this.push(null); return this.push(null);
once = true; once = true;
@ -27,7 +27,7 @@ FakeAgent.prototype.createConnection = function createConnection() {
}; };
// Blackhole // Blackhole
s._write = function write(data, enc, cb) { s._write = function _write(data, enc, cb) {
cb(); cb();
}; };

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

@ -166,7 +166,7 @@ const tests = [
expected: [prompt, replFailedRead, prompt, replDisabled, prompt] expected: [prompt, replFailedRead, prompt, replDisabled, prompt]
}, },
{ // Make sure this is always the last test, since we change os.homedir() { // Make sure this is always the last test, since we change os.homedir()
before: function mockHomedirFailure() { before: function before() {
// Mock os.homedir() failure // Mock os.homedir() failure
os.homedir = function() { os.homedir = function() {
throw new Error('os.homedir() failure'); throw new Error('os.homedir() failure');

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

@ -291,7 +291,7 @@ const testCustomCompleterSyncMode = repl.start({
prompt: '', prompt: '',
input: putIn, input: putIn,
output: putIn, output: putIn,
completer: function completerSyncMode(line) { completer: function completer(line) {
const hits = customCompletions.filter((c) => { const hits = customCompletions.filter((c) => {
return c.indexOf(line) === 0; return c.indexOf(line) === 0;
}); });
@ -323,7 +323,7 @@ const testCustomCompleterAsyncMode = repl.start({
prompt: '', prompt: '',
input: putIn, input: putIn,
output: putIn, output: putIn,
completer: function completerAsyncMode(line, callback) { completer: function completer(line, callback) {
const hits = customCompletions.filter((c) => { const hits = customCompletions.filter((c) => {
return c.indexOf(line) === 0; return c.indexOf(line) === 0;
}); });

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

@ -25,7 +25,7 @@ function Mediator() {
} }
util.inherits(Mediator, stream.Writable); util.inherits(Mediator, stream.Writable);
Mediator.prototype._write = function write(data, enc, cb) { Mediator.prototype._write = function _write(data, enc, cb) {
this.buf += data; this.buf += data;
setTimeout(cb, 0); setTimeout(cb, 0);

Loading…
Cancel
Save