| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9ebd559 commit 205bed0
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -608,10 +608,18 @@ ClientRequest.prototype.setTimeout = function(msecs, callback) { | |||
| 608 | 608 | }; | |
| 609 | 609 | ||
| 610 | 610 | ClientRequest.prototype.setNoDelay = function() { | |
| 611 | - this._deferToConnect('setNoDelay', arguments); | ||
| 611 | + const argsLen = arguments.length; | ||
| 612 | + const args = new Array(argsLen); | ||
| 613 | + for (var i = 0; i < argsLen; i++) | ||
| 614 | + args[i] = arguments[i]; | ||
| 615 | + this._deferToConnect('setNoDelay', args); | ||
| 612 | 616 | }; | |
| 613 | 617 | ClientRequest.prototype.setSocketKeepAlive = function() { | |
| 614 | - this._deferToConnect('setKeepAlive', arguments); | ||
| 618 | + const argsLen = arguments.length; | ||
| 619 | + const args = new Array(argsLen); | ||
| 620 | + for (var i = 0; i < argsLen; i++) | ||
| 621 | + args[i] = arguments[i]; | ||
| 622 | + this._deferToConnect('setKeepAlive', args); | ||
| 615 | 623 | }; | |
| 616 | 624 | ||
| 617 | 625 | ClientRequest.prototype.clearTimeout = function(cb) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -972,7 +972,11 @@ function normalizeConnectArgs(listArgs) { | |||
| 972 | 972 | } | |
| 973 | 973 | ||
| 974 | 974 | exports.connect = function(/* [port, host], options, cb */) { | |
| 975 | - var args = normalizeConnectArgs(arguments); | ||
| 975 | + const argsLen = arguments.length; | ||
| 976 | + var args = new Array(argsLen); | ||
| 977 | + for (var i = 0; i < argsLen; i++) | ||
| 978 | + args[i] = arguments[i]; | ||
| 979 | + args = normalizeConnectArgs(args); | ||
| 976 | 980 | var options = args[0]; | |
| 977 | 981 | var cb = args[1]; | |
| 978 | 982 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -290,6 +290,16 @@ function expectedException(actual, expected) { | |||
| 290 | 290 | return expected.call({}, actual) === true; | |
| 291 | 291 | } | |
| 292 | 292 | ||
| 293 | + function _tryBlock(block) { | ||
| 294 | + var error; | ||
| 295 | + try { | ||
| 296 | + block(); | ||
| 297 | + } catch (e) { | ||
| 298 | + error = e; | ||
| 299 | + } | ||
| 300 | + return error; | ||
| 301 | + } | ||
| 302 | + | ||
| 293 | 303 | function _throws(shouldThrow, block, expected, message) { | |
| 294 | 304 | var actual; | |
| 295 | 305 | ||
@@ -302,11 +312,7 @@ function _throws(shouldThrow, block, expected, message) { | |||
| 302 | 312 | expected = null; | |
| 303 | 313 | } | |
| 304 | 314 | ||
| 305 | - try { | ||
| 306 | - block(); | ||
| 307 | - } catch (e) { | ||
| 308 | - actual = e; | ||
| 309 | - } | ||
| 315 | + actual = _tryBlock(block); | ||
| 310 | 316 | ||
| 311 | 317 | message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + | |
| 312 | 318 | (message ? ' ' + message : '.'); | |
@@ -329,12 +335,12 @@ function _throws(shouldThrow, block, expected, message) { | |||
| 329 | 335 | // assert.throws(block, Error_opt, message_opt); | |
| 330 | 336 | ||
| 331 | 337 | assert.throws = function(block, /*optional*/error, /*optional*/message) { | |
| 332 | - _throws.apply(this, [true].concat(pSlice.call(arguments))); | ||
| 338 | + _throws(true, block, error, message); | ||
| 333 | 339 | }; | |
| 334 | 340 | ||
| 335 | 341 | // EXTENSION! This is annoying to write outside this module. | |
| 336 | - assert.doesNotThrow = function(block, /*optional*/message) { | ||
| 337 | - _throws.apply(this, [false].concat(pSlice.call(arguments))); | ||
| 342 | + assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { | ||
| 343 | + _throws(false, block, error, message); | ||
| 338 | 344 | }; | |
| 339 | 345 | ||
| 340 | 346 | assert.ifError = function(err) { if (err) throw err; }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -84,7 +84,10 @@ Console.prototype.trace = function trace() { | |||
| 84 | 84 | ||
| 85 | 85 | Console.prototype.assert = function(expression) { | |
| 86 | 86 | if (!expression) { | |
| 87 | - var arr = Array.prototype.slice.call(arguments, 1); | ||
| 87 | + const argsLen = arguments.length || 1; | ||
| 88 | + const arr = new Array(argsLen - 1); | ||
| 89 | + for (var i = 1; i < argsLen; i++) | ||
| 90 | + arr[i - 1] = arguments[i]; | ||
| 88 | 91 | require('assert').ok(false, util.format.apply(null, arr)); | |
| 89 | 92 | } | |
| 90 | 93 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,7 +59,11 @@ exports.createServer = function(options, connectionListener) { | |||
| 59 | 59 | // connect(path, [cb]); | |
| 60 | 60 | // | |
| 61 | 61 | exports.connect = exports.createConnection = function() { | |
| 62 | - var args = normalizeConnectArgs(arguments); | ||
| 62 | + const argsLen = arguments.length; | ||
| 63 | + var args = new Array(argsLen); | ||
| 64 | + for (var i = 0; i < argsLen; i++) | ||
| 65 | + args[i] = arguments[i]; | ||
| 66 | + args = normalizeConnectArgs(args); | ||
| 63 | 67 | debug('createConnection', args); | |
| 64 | 68 | var s = new Socket(args[0]); | |
| 65 | 69 | return Socket.prototype.connect.apply(s, args); | |
@@ -858,7 +862,11 @@ Socket.prototype.connect = function(options, cb) { | |||
| 858 | 862 | // Old API: | |
| 859 | 863 | // connect(port, [host], [cb]) | |
| 860 | 864 | // connect(path, [cb]); | |
| 861 | - var args = normalizeConnectArgs(arguments); | ||
| 865 | + const argsLen = arguments.length; | ||
| 866 | + var args = new Array(argsLen); | ||
| 867 | + for (var i = 0; i < argsLen; i++) | ||
| 868 | + args[i] = arguments[i]; | ||
| 869 | + args = normalizeConnectArgs(args); | ||
| 862 | 870 | return Socket.prototype.connect.apply(this, args); | |
| 863 | 871 | } | |
| 864 | 872 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments