Browse Source

test,lib,doc: use function declarations

Replace function expressions with function declarations in preparation
for a lint rule requiring function declarations.

PR-URL: https://github.com/nodejs/node/pull/12711
Backport-PR-URL: https://github.com/nodejs/node/pull/13774
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
v6.x
Rich Trott 8 years ago
committed by Myles Borins
parent
commit
7e6a956a29
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 2
      doc/api/util.md
  2. 2
      lib/_http_client.js
  3. 4
      lib/_tls_legacy.js
  4. 4
      lib/crypto.js
  5. 4
      test/addons/make-callback/test.js
  6. 8
      test/inspector/inspector-helper.js
  7. 3
      test/parallel/test-assert.js
  8. 4
      test/parallel/test-child-process-fork-dgram.js
  9. 12
      test/parallel/test-child-process-fork-net.js
  10. 4
      test/parallel/test-child-process-fork-net2.js
  11. 2
      test/parallel/test-child-process-spawn-typeerror.js
  12. 8
      test/parallel/test-cluster-disconnect.js
  13. 2
      test/parallel/test-cluster-master-error.js
  14. 2
      test/parallel/test-cluster-master-kill.js
  15. 2
      test/parallel/test-cluster-message.js
  16. 2
      test/parallel/test-cluster-worker-exit.js
  17. 2
      test/parallel/test-console-not-call-toString.js
  18. 2
      test/parallel/test-debugger-pid.js
  19. 4
      test/parallel/test-event-emitter-add-listeners.js
  20. 4
      test/parallel/test-event-emitter-once.js
  21. 6
      test/parallel/test-fs-access.js
  22. 6
      test/parallel/test-fs-link.js
  23. 4
      test/parallel/test-fs-read-stream-fd-leak.js
  24. 68
      test/parallel/test-http-parser.js
  25. 4
      test/parallel/test-http-response-status-message.js
  26. 2
      test/parallel/test-https-simple.js
  27. 8
      test/parallel/test-net-server-max-connections-close-makes-more-available.js
  28. 4
      test/parallel/test-net-server-pause-on-connect.js
  29. 2
      test/parallel/test-net-socket-timeout.js
  30. 4
      test/parallel/test-os.js
  31. 6
      test/parallel/test-preload.js
  32. 2
      test/parallel/test-querystring.js
  33. 4
      test/parallel/test-readline-interface.js
  34. 8
      test/parallel/test-stream2-pipe-error-once-listener.js
  35. 4
      test/parallel/test-timers-ordering.js
  36. 8
      test/parallel/test-util-inspect.js
  37. 4
      test/pseudo-tty/test-tty-stdout-end.js
  38. 6
      test/pummel/test-dtrace-jsstack.js
  39. 6
      test/pummel/test-tls-session-timeout.js

2
doc/api/util.md

@ -557,7 +557,7 @@ Returns `true` if the given `object` is a `Function`. Otherwise, returns
const util = require('util');
function Foo() {}
const Bar = function() {};
const Bar = () => {};
util.isFunction({});
// Returns: false

2
lib/_http_client.js

@ -606,7 +606,7 @@ ClientRequest.prototype._deferToConnect = function(method, arguments_, cb) {
cb();
}
var onSocket = function() {
var onSocket = () => {
if (self.socket.writable) {
callSocketMethod();
} else {

4
lib/_tls_legacy.js

@ -425,9 +425,9 @@ CryptoStream.prototype.destroySoon = function(err) {
// was written on this side was read from the other side.
var self = this;
var waiting = 1;
var finish = function() {
function finish() {
if (--waiting === 0) self.destroy();
};
}
this._opposite.once('end', finish);
if (!this._finished) {
this.once('finish', finish);

4
lib/crypto.js

@ -581,11 +581,11 @@ function pbkdf2(password, salt, iterations, keylen, digest, callback) {
// at this point, we need to handle encodings.
var encoding = exports.DEFAULT_ENCODING;
if (callback) {
var next = function(er, ret) {
function next(er, ret) {
if (ret)
ret = ret.toString(encoding);
callback(er, ret);
};
}
binding.PBKDF2(password, salt, iterations, keylen, digest, next);
} else {
var ret = binding.PBKDF2(password, salt, iterations, keylen, digest);

4
test/addons/make-callback/test.js

@ -57,9 +57,9 @@ const forward = vm.runInNewContext(`
})
`);
// Runs in outer context.
const endpoint = function($Object) {
function endpoint($Object) {
if (Object === $Object)
throw new Error('bad');
return Object;
};
}
assert.strictEqual(Object, makeCallback(process, forward, endpoint));

8
test/inspector/inspector-helper.js

@ -120,7 +120,7 @@ function timeout(message, multiplicator) {
TIMEOUT * (multiplicator || 1));
}
const TestSession = function(socket, harness) {
function TestSession(socket, harness) {
this.mainScriptPath = harness.mainScriptPath;
this.mainScriptId = null;
@ -145,7 +145,7 @@ const TestSession = function(socket, harness) {
buffer = buffer.slice(consumed);
} while (consumed);
}).on('close', () => assert(this.expectClose_, 'Socket closed prematurely'));
};
}
TestSession.prototype.scriptUrlForId = function(id) {
return this.scripts_[id];
@ -302,7 +302,7 @@ TestSession.prototype.testHttpResponse = function(path, check) {
};
const Harness = function(port, childProcess) {
function Harness(port, childProcess) {
this.port = port;
this.mainScriptPath = mainScript;
this.stderrFilters_ = [];
@ -327,7 +327,7 @@ const Harness = function(port, childProcess) {
this.returnCode_ = code;
this.running_ = false;
});
};
}
Harness.prototype.addStderrFilter = function(regexp, callback) {
this.stderrFilters_.push((message) => {

3
test/parallel/test-assert.js

@ -428,7 +428,7 @@ try {
AnotherErrorType = class extends Error {};
const functionThatThrows = function() {
const functionThatThrows = () => {
throw new AnotherErrorType('foo');
};
@ -471,6 +471,7 @@ a.throws(makeBlock(a.deepEqual, args, []));
// more checking that arguments objects are handled correctly
{
// eslint-disable-next-line func-style
const returnArguments = function() { return arguments; };
const someArgs = returnArguments('a');

4
test/parallel/test-child-process-fork-dgram.js

@ -57,7 +57,7 @@ if (process.argv[2] === 'child') {
});
});
const sendMessages = function() {
function sendMessages() {
const serverPort = parentServer.address().port;
const timer = setInterval(function() {
@ -81,7 +81,7 @@ if (process.argv[2] === 'child') {
);
}
}, 1);
};
}
parentServer.bind(0, '127.0.0.1');

12
test/parallel/test-child-process-fork-net.js

@ -66,7 +66,7 @@ if (process.argv[2] === 'child') {
}));
// send net.Server to child and test by connecting
const testServer = function(callback) {
function testServer(callback) {
// destroy server execute callback when done
const progress = new ProgressTracker(2, function() {
@ -95,7 +95,7 @@ if (process.argv[2] === 'child') {
server.listen(0);
// handle client messages
const messageHandlers = function(msg) {
function messageHandlers(msg) {
if (msg.what === 'listening') {
// make connections
@ -117,13 +117,13 @@ if (process.argv[2] === 'child') {
child.removeListener('message', messageHandlers);
callback();
}
};
}
child.on('message', messageHandlers);
};
}
// send net.Socket to child
const testSocket = function(callback) {
function testSocket(callback) {
// create a new server and connect to it,
// but the socket will be handled by the child
@ -158,7 +158,7 @@ if (process.argv[2] === 'child') {
server.close();
});
});
};
}
// create server and send it to child
let serverSuccess = false;

4
test/parallel/test-child-process-fork-net2.js

@ -123,7 +123,7 @@ if (process.argv[2] === 'child') {
server.listen(0, '127.0.0.1');
let closeServer = function() {
function closeServer() {
server.close();
setTimeout(function() {
@ -132,7 +132,7 @@ if (process.argv[2] === 'child') {
child2.send('close');
child3.disconnect();
}, 200);
};
}
process.on('exit', function() {
assert.strictEqual(disconnected, count);

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

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

8
test/parallel/test-cluster-disconnect.js

@ -17,7 +17,7 @@ if (cluster.isWorker) {
const servers = 2;
// test a single TCP server
const testConnection = function(port, cb) {
const testConnection = (port, cb) => {
const socket = net.connect(port, '127.0.0.1', () => {
// buffer result
let result = '';
@ -31,7 +31,7 @@ if (cluster.isWorker) {
};
// test both servers created in the cluster
const testCluster = function(cb) {
const testCluster = (cb) => {
let done = 0;
for (let i = 0; i < servers; i++) {
@ -46,7 +46,7 @@ if (cluster.isWorker) {
};
// start two workers and execute callback when both is listening
const startCluster = function(cb) {
const startCluster = (cb) => {
const workers = 8;
let online = 0;
@ -60,7 +60,7 @@ if (cluster.isWorker) {
}
};
const test = function(again) {
const test = (again) => {
//1. start cluster
startCluster(common.mustCall(() => {
//2. test cluster

2
test/parallel/test-cluster-master-error.js

@ -80,7 +80,7 @@ if (cluster.isWorker) {
// Check that the cluster died accidentally (non-zero exit code)
masterExited = !!code;
const pollWorkers = function() {
const pollWorkers = () => {
// When master is dead all workers should be dead too
let alive = false;
workers.forEach((pid) => alive = common.isAlive(pid));

2
test/parallel/test-cluster-master-kill.js

@ -47,7 +47,7 @@ if (cluster.isWorker) {
assert.strictEqual(code, 0);
// check worker process status
const pollWorker = function() {
const pollWorker = () => {
alive = common.isAlive(pid);
if (alive) {
setTimeout(pollWorker, 50);

2
test/parallel/test-cluster-message.js

@ -59,7 +59,7 @@ if (cluster.isWorker) {
let client;
const check = function(type, result) {
const check = (type, result) => {
checks[type].receive = true;
checks[type].correct = result;
console.error('check', checks);

2
test/parallel/test-cluster-worker-exit.js

@ -82,7 +82,7 @@ if (cluster.isWorker) {
}
}));
const finish_test = function() {
const finish_test = () => {
try {
checkResults(expected_results, results);
} catch (exc) {

2
test/parallel/test-console-not-call-toString.js

@ -2,7 +2,7 @@
require('../common');
const assert = require('assert');
const func = function() {};
function func() {}
let toStringCalled = false;
func.toString = function() {
toStringCalled = true;

2
test/parallel/test-debugger-pid.js

@ -11,7 +11,7 @@ const interfacer = spawn(process.execPath, ['debug', '-p', '655555']);
console.error(process.execPath, 'debug', '-p', '655555');
interfacer.stdout.setEncoding('utf-8');
interfacer.stderr.setEncoding('utf-8');
const onData = function(data) {
const onData = (data) => {
data = (buffer + data).split('\n');
buffer = data.pop();
data.forEach(function(line) {

4
test/parallel/test-event-emitter-add-listeners.js

@ -47,8 +47,8 @@ const EventEmitter = require('events');
}
{
const listen1 = function listen1() {};
const listen2 = function listen2() {};
const listen1 = () => {};
const listen2 = () => {};
const ee = new EventEmitter();
ee.once('newListener', function() {

4
test/parallel/test-event-emitter-once.js

@ -12,9 +12,9 @@ e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
const remove = function() {
function remove() {
common.fail('once->foo should not be emitted');
};
}
e.once('foo', remove);
e.removeListener('foo', remove);

6
test/parallel/test-fs-access.js

@ -7,7 +7,7 @@ const doesNotExist = path.join(common.tmpDir, '__this_should_not_exist');
const readOnlyFile = path.join(common.tmpDir, 'read_only_file');
const readWriteFile = path.join(common.tmpDir, 'read_write_file');
const removeFile = function(file) {
const removeFile = (file) => {
try {
fs.unlinkSync(file);
} catch (err) {
@ -15,11 +15,11 @@ const removeFile = function(file) {
}
};
const createFileWithPerms = function(file, mode) {
function createFileWithPerms(file, mode) {
removeFile(file);
fs.writeFileSync(file, '');
fs.chmodSync(file, mode);
};
}
common.refreshTmpDir();
createFileWithPerms(readOnlyFile, 0o444);

6
test/parallel/test-fs-link.js

@ -11,11 +11,11 @@ const srcPath = path.join(common.tmpDir, 'hardlink-target.txt');
const dstPath = path.join(common.tmpDir, 'link1.js');
fs.writeFileSync(srcPath, 'hello world');
const callback = function(err) {
if (err) throw err;
function callback(err) {
assert.ifError(err);
const dstContent = fs.readFileSync(dstPath, 'utf8');
assert.strictEqual('hello world', dstContent);
};
}
fs.link(srcPath, dstPath, common.mustCall(callback));

4
test/parallel/test-fs-read-stream-fd-leak.js

@ -29,7 +29,7 @@ function testLeak(endFn, callback) {
let i = 0;
let check = 0;
const checkFunction = function() {
function checkFunction() {
if (openCount !== 0 && check < totalCheck) {
check++;
setTimeout(checkFunction, 100);
@ -44,7 +44,7 @@ function testLeak(endFn, callback) {
openCount = 0;
callback && setTimeout(callback, 100);
};
}
setInterval(function() {
const s = fs.createReadStream(emptyTxt);

68
test/parallel/test-http-parser.js

@ -77,9 +77,9 @@ function expectBody(expected) {
'GET /hello HTTP/1.1' + CRLF +
CRLF);
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 1);
assert.strictEqual(method, methods.indexOf('GET'));
@ -118,9 +118,9 @@ function expectBody(expected) {
CRLF +
'pong');
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, undefined);
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 1);
@ -128,7 +128,7 @@ function expectBody(expected) {
assert.strictEqual(statusMessage, 'OK');
};
const onBody = function(buf, start, len) {
const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, 'pong');
};
@ -148,9 +148,9 @@ function expectBody(expected) {
'HTTP/1.0 200 Connection established' + CRLF +
CRLF);
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 0);
assert.strictEqual(method, undefined);
@ -182,15 +182,15 @@ function expectBody(expected) {
let seen_body = false;
const onHeaders = function(headers, url) {
const onHeaders = (headers, url) => {
assert.ok(seen_body); // trailers should come after the body
assert.deepStrictEqual(headers,
['Vary', '*', 'Content-Type', 'text/plain']);
};
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
@ -199,7 +199,7 @@ function expectBody(expected) {
parser[kOnHeaders] = mustCall(onHeaders);
};
const onBody = function(buf, start, len) {
const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, 'ping');
seen_body = true;
@ -223,9 +223,9 @@ function expectBody(expected) {
'X-Filler2: 42' + CRLF +
CRLF);
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('GET'));
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 0);
@ -253,9 +253,9 @@ function expectBody(expected) {
lots_of_headers +
CRLF);
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('GET'));
assert.strictEqual(url || parser.url, '/foo/bar/baz?quux=42#1337');
assert.strictEqual(versionMajor, 1);
@ -287,16 +287,16 @@ function expectBody(expected) {
CRLF +
'foo=42&bar=1337');
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 1);
};
const onBody = function(buf, start, len) {
const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, 'foo=42&bar=1337');
};
@ -325,9 +325,9 @@ function expectBody(expected) {
'1234567890' + CRLF +
'0' + CRLF);
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
@ -337,7 +337,7 @@ function expectBody(expected) {
let body_part = 0;
const body_parts = ['123', '123456', '1234567890'];
const onBody = function(buf, start, len) {
const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, body_parts[body_part++]);
};
@ -363,9 +363,9 @@ function expectBody(expected) {
'6' + CRLF +
'123456' + CRLF);
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
@ -376,7 +376,7 @@ function expectBody(expected) {
const body_parts =
['123', '123456', '123456789', '123456789ABC', '123456789ABCDEF'];
const onBody = function(buf, start, len) {
const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, body_parts[body_part++]);
};
@ -421,9 +421,9 @@ function expectBody(expected) {
'0' + CRLF);
function test(a, b) {
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/helpme');
assert.strictEqual(versionMajor, 1);
@ -432,7 +432,7 @@ function expectBody(expected) {
let expected_body = '123123456123456789123456789ABC123456789ABCDEF';
const onBody = function(buf, start, len) {
const onBody = (buf, start, len) => {
const chunk = '' + buf.slice(start, start + len);
assert.strictEqual(expected_body.indexOf(chunk), 0);
expected_body = expected_body.slice(chunk.length);
@ -480,9 +480,9 @@ function expectBody(expected) {
'123456789ABCDEF' + CRLF +
'0' + CRLF);
const onHeadersComplete = function(versionMajor, versionMinor, headers,
const onHeadersComplete = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
@ -494,7 +494,7 @@ function expectBody(expected) {
let expected_body = '123123456123456789123456789ABC123456789ABCDEF';
const onBody = function(buf, start, len) {
const onBody = (buf, start, len) => {
const chunk = '' + buf.slice(start, start + len);
assert.strictEqual(expected_body.indexOf(chunk), 0);
expected_body = expected_body.slice(chunk.length);
@ -532,9 +532,9 @@ function expectBody(expected) {
CRLF +
'pong');
const onHeadersComplete1 = function(versionMajor, versionMinor, headers,
const onHeadersComplete1 = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('PUT'));
assert.strictEqual(url, '/this');
assert.strictEqual(versionMajor, 1);
@ -544,9 +544,9 @@ function expectBody(expected) {
['Content-Type', 'text/plain', 'Transfer-Encoding', 'chunked']);
};
const onHeadersComplete2 = function(versionMajor, versionMinor, headers,
const onHeadersComplete2 = (versionMajor, versionMinor, headers,
method, url, statusCode, statusMessage,
upgrade, shouldKeepAlive) {
upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url, '/that');
assert.strictEqual(versionMajor, 1);

4
test/parallel/test-http-response-status-message.js

@ -38,7 +38,7 @@ const server = net.createServer(function(connection) {
});
});
const runTest = function(testCaseIndex) {
function runTest(testCaseIndex) {
const testCase = testCases[testCaseIndex];
http.get({
@ -61,7 +61,7 @@ const runTest = function(testCaseIndex) {
response.resume();
});
};
}
server.listen(0, function() { runTest(0); });

2
test/parallel/test-https-simple.js

@ -18,7 +18,7 @@ const options = {
const tests = 2;
let successful = 0;
const testSucceeded = function() {
const testSucceeded = () => {
successful = successful + 1;
if (successful === tests) {
server.close();

8
test/parallel/test-net-server-max-connections-close-makes-more-available.js

@ -17,7 +17,7 @@ const connections = [];
const received = [];
const sent = [];
const createConnection = function(index) {
function createConnection(index) {
console.error('creating connection ' + index);
return new Promise(function(resolve, reject) {
@ -45,9 +45,9 @@ const createConnection = function(index) {
connections[index] = connection;
});
};
}
const closeConnection = function(index) {
function closeConnection(index) {
console.error('closing connection ' + index);
return new Promise(function(resolve, reject) {
connections[index].on('end', function() {
@ -55,7 +55,7 @@ const closeConnection = function(index) {
});
connections[index].end();
});
};
}
let server = net.createServer(function(socket) {
socket.on('data', function(data) {

4
test/parallel/test-net-server-pause-on-connect.js

@ -7,7 +7,7 @@ let stopped = true;
let server1Sock;
const server1ConnHandler = function(socket) {
const server1ConnHandler = (socket) => {
socket.on('data', function(data) {
if (stopped) {
common.fail('data event should not have happened yet');
@ -23,7 +23,7 @@ const server1ConnHandler = function(socket) {
const server1 = net.createServer({pauseOnConnect: true}, server1ConnHandler);
const server2ConnHandler = function(socket) {
const server2ConnHandler = (socket) => {
socket.on('data', function(data) {
assert.strictEqual(data.toString(), msg, 'invalid data received');
socket.end();

2
test/parallel/test-net-socket-timeout.js

@ -4,7 +4,7 @@ const net = require('net');
const assert = require('assert');
// Verify that invalid delays throw
const noop = function() {};
const noop = () => {};
const s = new net.Socket();
const nonNumericDelays = [
'100', true, false, undefined, null, '', {}, noop, []

4
test/parallel/test-os.js

@ -104,7 +104,7 @@ console.error(interfaces);
switch (platform) {
case 'linux':
{
const filter = function(e) { return e.address === '127.0.0.1'; };
const filter = (e) => e.address === '127.0.0.1';
const actual = interfaces.lo.filter(filter);
const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0',
mac: '00:00:00:00:00:00', family: 'IPv4',
@ -114,7 +114,7 @@ switch (platform) {
}
case 'win32':
{
const filter = function(e) { return e.address === '127.0.0.1'; };
const filter = (e) => e.address === '127.0.0.1';
const actual = interfaces['Loopback Pseudo-Interface 1'].filter(filter);
const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0',
mac: '00:00:00:00:00:00', family: 'IPv4',

6
test/parallel/test-preload.js

@ -13,7 +13,7 @@ if (common.isSunOS) {
const nodeBinary = process.argv[0];
const preloadOption = function(preloads) {
const preloadOption = (preloads) => {
let option = '';
preloads.forEach(function(preload, index) {
option += '-r ' + preload + ' ';
@ -21,9 +21,7 @@ const preloadOption = function(preloads) {
return option;
};
const fixture = function(name) {
return path.join(common.fixturesDir, name);
};
const fixture = (name) => path.join(common.fixturesDir, name);
const fixtureA = fixture('printA.js');
const fixtureB = fixture('printB.js');

2
test/parallel/test-querystring.js

@ -67,7 +67,7 @@ const qsColonTestCases = [
];
// [wonkyObj, qs, canonicalObj]
const extendedFunction = function() {};
function extendedFunction() {}
extendedFunction.prototype = {a: 'b'};
const qsWeirdObjects = [
[{regexp: /./g}, 'regexp=', {'regexp': ''}],

4
test/parallel/test-readline-interface.js

@ -265,9 +265,7 @@ function isWarned(emitter) {
// \t does not become part of the input when there is a completer function
fi = new FakeInput();
const completer = function(line) {
return [[], line];
};
const completer = (line) => [[], line];
rli = new readline.Interface({
input: fi,
output: fi,

8
test/parallel/test-stream2-pipe-error-once-listener.js

@ -5,9 +5,9 @@ const util = require('util');
const stream = require('stream');
const Read = function() {
function Read() {
stream.Readable.call(this);
};
}
util.inherits(Read, stream.Readable);
Read.prototype._read = function(size) {
@ -16,9 +16,9 @@ Read.prototype._read = function(size) {
};
const Write = function() {
function Write() {
stream.Writable.call(this);
};
}
util.inherits(Write, stream.Writable);
Write.prototype._write = function(buffer, encoding, cb) {

4
test/parallel/test-timers-ordering.js

@ -8,7 +8,7 @@ const N = 30;
let last_i = 0;
let last_ts = 0;
const f = function(i) {
function f(i) {
if (i <= N) {
// check order
assert.strictEqual(i, last_i + 1, 'order is broken: ' + i + ' != ' +
@ -25,5 +25,5 @@ const f = function(i) {
// schedule next iteration
setTimeout(f, 1, i + 1);
}
};
}
f(1);

8
test/parallel/test-util-inspect.js

@ -252,9 +252,11 @@ Object.defineProperty(
assert.strictEqual(util.inspect(value), '[ 1, 2, 3, growingLength: [Getter] ]');
// Function with properties
value = function() {};
{
const value = () => {};
value.aprop = 42;
assert.strictEqual(util.inspect(value), '{ [Function: value] aprop: 42 }');
}
// Anonymous function with properties
value = (() => function() {})();
@ -595,9 +597,7 @@ assert.doesNotThrow(function() {
// util.inspect with "colors" option should produce as many lines as without it
function test_lines(input) {
const count_lines = function(str) {
return (str.match(/\n/g) || []).length;
};
const count_lines = (str) => (str.match(/\n/g) || []).length;
const without_color = util.inspect(input);
const with_color = util.inspect(input, {colors: true});

4
test/pseudo-tty/test-tty-stdout-end.js

@ -2,11 +2,11 @@
require('../common');
const assert = require('assert');
const shouldThrow = function() {
const shouldThrow = () => {
process.stdout.end();
};
const validateError = function(e) {
const validateError = (e) => {
return e instanceof Error &&
e.message === 'process.stdout cannot be closed.';
};

6
test/pummel/test-dtrace-jsstack.js

@ -13,18 +13,18 @@ if (!common.isSunOS) {
*/
const frames = [ 'stalloogle', 'bagnoogle', 'doogle' ];
const stalloogle = function(str) {
const stalloogle = (str) => {
global.expected = str;
os.loadavg();
};
const bagnoogle = function(arg0, arg1) {
const bagnoogle = (arg0, arg1) => {
stalloogle(arg0 + ' is ' + arg1 + ' except that it is read-only');
};
let done = false;
const doogle = function() {
const doogle = () => {
if (!done)
setTimeout(doogle, 10);

6
test/pummel/test-tls-session-timeout.js

@ -57,7 +57,7 @@ function doTest() {
// Expects a callback -- cb(connectionType : enum ['New'|'Reused'])
const Client = function(cb) {
function Client(cb) {
const flags = [
's_client',
'-connect', 'localhost:' + common.PORT,
@ -74,7 +74,7 @@ function doTest() {
});
client.on('exit', function(code) {
let connectionType;
const grepConnectionType = function(line) {
const grepConnectionType = (line) => {
const matches = line.match(/(New|Reused), /);
if (matches) {
connectionType = matches[1];
@ -87,7 +87,7 @@ function doTest() {
}
cb(connectionType);
});
};
}
const server = tls.createServer(options, function(cleartext) {
cleartext.on('error', function(er) {

Loading…
Cancel
Save