};
ClientRequest.prototype.setNoDelay = function() {
- this._deferToConnect('setNoDelay', arguments);
+ const argsLen = arguments.length;
+ const args = new Array(argsLen);
+ for (var i = 0; i < argsLen; i++)
+ args[i] = arguments[i];
+ this._deferToConnect('setNoDelay', args);
};
ClientRequest.prototype.setSocketKeepAlive = function() {
- this._deferToConnect('setKeepAlive', arguments);
+ const argsLen = arguments.length;
+ const args = new Array(argsLen);
+ for (var i = 0; i < argsLen; i++)
+ args[i] = arguments[i];
+ this._deferToConnect('setKeepAlive', args);
};
ClientRequest.prototype.clearTimeout = function(cb) {
}
exports.connect = function(/* [port, host], options, cb */) {
- var args = normalizeConnectArgs(arguments);
+ const argsLen = arguments.length;
+ var args = new Array(argsLen);
+ for (var i = 0; i < argsLen; i++)
+ args[i] = arguments[i];
+ args = normalizeConnectArgs(args);
var options = args[0];
var cb = args[1];
return expected.call({}, actual) === true;
}
+function _tryBlock(block) {
+ var error;
+ try {
+ block();
+ } catch (e) {
+ error = e;
+ }
+ return error;
+}
+
function _throws(shouldThrow, block, expected, message) {
var actual;
expected = null;
}
- try {
- block();
- } catch (e) {
- actual = e;
- }
+ actual = _tryBlock(block);
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
(message ? ' ' + message : '.');
// assert.throws(block, Error_opt, message_opt);
assert.throws = function(block, /*optional*/error, /*optional*/message) {
- _throws.apply(this, [true].concat(pSlice.call(arguments)));
+ _throws(true, block, error, message);
};
// EXTENSION! This is annoying to write outside this module.
-assert.doesNotThrow = function(block, /*optional*/message) {
- _throws.apply(this, [false].concat(pSlice.call(arguments)));
+assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
+ _throws(false, block, error, message);
};
assert.ifError = function(err) { if (err) throw err; };
Console.prototype.assert = function(expression) {
if (!expression) {
- var arr = Array.prototype.slice.call(arguments, 1);
+ const argsLen = arguments.length || 1;
+ const arr = new Array(argsLen - 1);
+ for (var i = 1; i < argsLen; i++)
+ arr[i - 1] = arguments[i];
require('assert').ok(false, util.format.apply(null, arr));
}
};
// connect(path, [cb]);
//
exports.connect = exports.createConnection = function() {
- var args = normalizeConnectArgs(arguments);
+ const argsLen = arguments.length;
+ var args = new Array(argsLen);
+ for (var i = 0; i < argsLen; i++)
+ args[i] = arguments[i];
+ args = normalizeConnectArgs(args);
debug('createConnection', args);
var s = new Socket(args[0]);
return Socket.prototype.connect.apply(s, args);
// Old API:
// connect(port, [host], [cb])
// connect(path, [cb]);
- var args = normalizeConnectArgs(arguments);
+ const argsLen = arguments.length;
+ var args = new Array(argsLen);
+ for (var i = 0; i < argsLen; i++)
+ args[i] = arguments[i];
+ args = normalizeConnectArgs(args);
return Socket.prototype.connect.apply(this, args);
}