| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4e9212b commit ee9e2a2
20 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,11 +22,9 @@ | |||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | - ArrayPrototypePushApply, | ||
| 26 | 25 | MathMin, | |
| 27 | 26 | Symbol, | |
| 28 | 27 | RegExpPrototypeTest, | |
| 29 | - TypedArrayPrototypeSlice, | ||
| 30 | 28 | } = primordials; | |
| 31 | 29 | const { setImmediate } = require('timers'); | |
| 32 | 30 | ||
@@ -66,7 +64,7 @@ function parserOnHeaders(headers, url) { | |||
| 66 | 64 | // Once we exceeded headers limit - stop collecting them | |
| 67 | 65 | if (this.maxHeaderPairs <= 0 || | |
| 68 | 66 | this._headers.length < this.maxHeaderPairs) { | |
| 69 | - ArrayPrototypePushApply(this._headers, headers); | ||
| 67 | + this._headers.push(...headers); | ||
| 70 | 68 | } | |
| 71 | 69 | this._url += url; | |
| 72 | 70 | } | |
@@ -138,7 +136,7 @@ function parserOnBody(b, start, len) { | |||
| 138 | 136 | ||
| 139 | 137 | // Pretend this was the result of a stream._read call. | |
| 140 | 138 | if (len > 0 && !stream._dumped) { | |
| 141 | - const slice = TypedArrayPrototypeSlice(b, start, start + len); | ||
| 139 | + const slice = b.slice(start, start + len); | ||
| 142 | 140 | const ret = stream.push(slice); | |
| 143 | 141 | if (!ret) | |
| 144 | 142 | readStop(this.socket); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,8 +22,6 @@ | |||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | - ArrayPrototypePush, | ||
| 26 | - FunctionPrototypeCall, | ||
| 27 | 25 | ObjectDefineProperty, | |
| 28 | 26 | ObjectSetPrototypeOf, | |
| 29 | 27 | StringPrototypeCharCodeAt, | |
@@ -59,7 +57,7 @@ function IncomingMessage(socket) { | |||
| 59 | 57 | }; | |
| 60 | 58 | } | |
| 61 | 59 | ||
| 62 | - FunctionPrototypeCall(Readable, this, streamOptions); | ||
| 60 | + Readable.call(this, streamOptions); | ||
| 63 | 61 | ||
| 64 | 62 | this._readableState.readingMore = true; | |
| 65 | 63 | ||
@@ -350,7 +348,7 @@ function _addHeaderLine(field, value, dest) { | |||
| 350 | 348 | } else if (flag === 1) { | |
| 351 | 349 | // Array header -- only Set-Cookie at the moment | |
| 352 | 350 | if (dest['set-cookie'] !== undefined) { | |
| 353 | - ArrayPrototypePush(dest['set-cookie'], value); | ||
| 351 | + dest['set-cookie'].push(value); | ||
| 354 | 352 | } else { | |
| 355 | 353 | dest['set-cookie'] = [value]; | |
| 356 | 354 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,13 +24,7 @@ | |||
| 24 | 24 | const { | |
| 25 | 25 | Array, | |
| 26 | 26 | ArrayIsArray, | |
| 27 | - ArrayPrototypeForEach, | ||
| 28 | 27 | ArrayPrototypeJoin, | |
| 29 | - ArrayPrototypePush, | ||
| 30 | - ArrayPrototypeUnshift, | ||
| 31 | - FunctionPrototype, | ||
| 32 | - FunctionPrototypeBind, | ||
| 33 | - FunctionPrototypeCall, | ||
| 34 | 28 | MathFloor, | |
| 35 | 29 | NumberPrototypeToString, | |
| 36 | 30 | ObjectCreate, | |
@@ -88,7 +82,7 @@ const { CRLF } = common; | |||
| 88 | 82 | ||
| 89 | 83 | const kCorked = Symbol('corked'); | |
| 90 | 84 | ||
| 91 | - const nop = FunctionPrototype; | ||
| 85 | + const nop = () => {}; | ||
| 92 | 86 | ||
| 93 | 87 | const RE_CONN_CLOSE = /(?:^|\W)close(?:$|\W)/i; | |
| 94 | 88 | const RE_TE_CHUNKED = common.chunkExpression; | |
@@ -101,7 +95,7 @@ function isCookieField(s) { | |||
| 101 | 95 | } | |
| 102 | 96 | ||
| 103 | 97 | function OutgoingMessage() { | |
| 104 | - FunctionPrototypeCall(Stream, this); | ||
| 98 | + Stream.call(this); | ||
| 105 | 99 | ||
| 106 | 100 | // Queue that holds all currently pending data, until the response will be | |
| 107 | 101 | // assigned to the socket (until it will its turn in the HTTP pipeline). | |
@@ -331,7 +325,7 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) { | |||
| 331 | 325 | data = this._header + data; | |
| 332 | 326 | } else { | |
| 333 | 327 | const header = this._header; | |
| 334 | - ArrayPrototypeUnshift(this.outputData, { | ||
| 328 | + this.outputData.unshift({ | ||
| 335 | 329 | data: header, | |
| 336 | 330 | encoding: 'latin1', | |
| 337 | 331 | callback: null | |
@@ -368,7 +362,7 @@ function _writeRaw(data, encoding, callback) { | |||
| 368 | 362 | return conn.write(data, encoding, callback); | |
| 369 | 363 | } | |
| 370 | 364 | // Buffer, as long as we're not destroyed. | |
| 371 | - ArrayPrototypePush(this.outputData, { data, encoding, callback }); | ||
| 365 | + this.outputData.push({ data, encoding, callback }); | ||
| 372 | 366 | this.outputSize += data.length; | |
| 373 | 367 | this._onPendingData(data.length); | |
| 374 | 368 | return this.outputSize < HIGH_WATER_MARK; | |
@@ -397,9 +391,10 @@ function _storeHeader(firstLine, headers) { | |||
| 397 | 391 | } | |
| 398 | 392 | } else if (ArrayIsArray(headers)) { | |
| 399 | 393 | if (headers.length && ArrayIsArray(headers[0])) { | |
| 400 | - ArrayPrototypeForEach(headers, (entry) => | ||
| 401 | - processHeader(this, state, entry[0], entry[1], true) | ||
| 402 | - ); | ||
| 394 | + for (let i = 0; i < headers.length; i++) { | ||
| 395 | + const entry = headers[i]; | ||
| 396 | + processHeader(this, state, entry[0], entry[1], true); | ||
| 397 | + } | ||
| 403 | 398 | } else { | |
| 404 | 399 | if (headers.length % 2 !== 0) { | |
| 405 | 400 | throw new ERR_INVALID_ARG_VALUE('headers', headers); | |
@@ -877,7 +872,7 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) { | |||
| 877 | 872 | if (typeof callback === 'function') | |
| 878 | 873 | this.once('finish', callback); | |
| 879 | 874 | ||
| 880 | - const finish = FunctionPrototypeBind(onFinish, undefined, this); | ||
| 875 | + const finish = onFinish.bind(undefined, this); | ||
| 881 | 876 | ||
| 882 | 877 | if (this._hasBody && this.chunkedEncoding) { | |
| 883 | 878 | this._send('0\r\n' + this._trailer + '\r\n', 'latin1', finish); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,20 +23,12 @@ | |||
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | 25 | ArrayIsArray, | |
| 26 | - ArrayPrototypeForEach, | ||
| 27 | - ArrayPrototypePush, | ||
| 28 | - ArrayPrototypeShift, | ||
| 29 | 26 | Error, | |
| 30 | - FunctionPrototype, | ||
| 31 | - FunctionPrototypeBind, | ||
| 32 | - FunctionPrototypeCall, | ||
| 33 | 27 | ObjectKeys, | |
| 34 | 28 | ObjectSetPrototypeOf, | |
| 35 | - ReflectApply, | ||
| 36 | 29 | RegExpPrototypeTest, | |
| 37 | 30 | Symbol, | |
| 38 | 31 | SymbolFor, | |
| 39 | - TypedArrayPrototypeSlice, | ||
| 40 | 32 | } = primordials; | |
| 41 | 33 | ||
| 42 | 34 | const net = require('net'); | |
@@ -185,7 +177,7 @@ class HTTPServerAsyncResource { | |||
| 185 | 177 | } | |
| 186 | 178 | ||
| 187 | 179 | function ServerResponse(req) { | |
| 188 | - FunctionPrototypeCall(OutgoingMessage, this); | ||
| 180 | + OutgoingMessage.call(this); | ||
| 189 | 181 | ||
| 190 | 182 | if (req.method === 'HEAD') this._hasBody = false; | |
| 191 | 183 | ||
@@ -212,7 +204,7 @@ ObjectSetPrototypeOf(ServerResponse, OutgoingMessage); | |||
| 212 | 204 | ServerResponse.prototype._finish = function _finish() { | |
| 213 | 205 | DTRACE_HTTP_SERVER_RESPONSE(this.socket); | |
| 214 | 206 | emitStatistics(this[kServerResponseStatistics]); | |
| 215 | - FunctionPrototypeCall(OutgoingMessage.prototype._finish, this); | ||
| 207 | + OutgoingMessage.prototype._finish.call(this); | ||
| 216 | 208 | }; | |
| 217 | 209 | ||
| 218 | 210 | ||
@@ -386,7 +378,7 @@ function Server(options, requestListener) { | |||
| 386 | 378 | validateBoolean(insecureHTTPParser, 'options.insecureHTTPParser'); | |
| 387 | 379 | this.insecureHTTPParser = insecureHTTPParser; | |
| 388 | 380 | ||
| 389 | - FunctionPrototypeCall(net.Server, this, { allowHalfOpen: true }); | ||
| 381 | + net.Server.call(this, { allowHalfOpen: true }); | ||
| 390 | 382 | ||
| 391 | 383 | if (requestListener) { | |
| 392 | 384 | this.on('request', requestListener); | |
@@ -422,17 +414,19 @@ Server.prototype[EE.captureRejectionSymbol] = function(err, event, ...args) { | |||
| 422 | 414 | const { 1: res } = args; | |
| 423 | 415 | if (!res.headersSent && !res.writableEnded) { | |
| 424 | 416 | // Don't leak headers. | |
| 425 | - ArrayPrototypeForEach(res.getHeaderNames(), | ||
| 426 | - (name) => res.removeHeader(name)); | ||
| 417 | + const names = res.getHeaderNames(); | ||
| 418 | + for (let i = 0; i < names.length; i++) { | ||
| 419 | + res.removeHeader(names[i]); | ||
| 420 | + } | ||
| 427 | 421 | res.statusCode = 500; | |
| 428 | 422 | res.end(STATUS_CODES[500]); | |
| 429 | 423 | } else { | |
| 430 | 424 | res.destroy(); | |
| 431 | 425 | } | |
| 432 | 426 | break; | |
| 433 | 427 | default: | |
| 434 | - ReflectApply(net.Server.prototype[SymbolFor('nodejs.rejection')], | ||
| 435 | - this, arguments); | ||
| 428 | + net.Server.prototype[SymbolFor('nodejs.rejection')] | ||
| 429 | + .apply(this, arguments); | ||
| 436 | 430 | } | |
| 437 | 431 | }; | |
| 438 | 432 | ||
@@ -493,20 +487,20 @@ function connectionListenerInternal(server, socket) { | |||
| 493 | 487 | outgoingData: 0, | |
| 494 | 488 | keepAliveTimeoutSet: false | |
| 495 | 489 | }; | |
| 496 | - state.onData = FunctionPrototypeBind(socketOnData, undefined, | ||
| 497 | - server, socket, parser, state); | ||
| 498 | - state.onEnd = FunctionPrototypeBind(socketOnEnd, undefined, | ||
| 499 | - server, socket, parser, state); | ||
| 500 | - state.onClose = FunctionPrototypeBind(socketOnClose, undefined, | ||
| 501 | - socket, state); | ||
| 502 | - state.onDrain = FunctionPrototypeBind(socketOnDrain, undefined, | ||
| 503 | - socket, state); | ||
| 490 | + state.onData = socketOnData.bind(undefined, | ||
| 491 | + server, socket, parser, state); | ||
| 492 | + state.onEnd = socketOnEnd.bind(undefined, | ||
| 493 | + server, socket, parser, state); | ||
| 494 | + state.onClose = socketOnClose.bind(undefined, | ||
| 495 | + socket, state); | ||
| 496 | + state.onDrain = socketOnDrain.bind(undefined, | ||
| 497 | + socket, state); | ||
| 504 | 498 | socket.on('data', state.onData); | |
| 505 | 499 | socket.on('error', socketOnError); | |
| 506 | 500 | socket.on('end', state.onEnd); | |
| 507 | 501 | socket.on('close', state.onClose); | |
| 508 | 502 | socket.on('drain', state.onDrain); | |
| 509 | - parser.onIncoming = FunctionPrototypeBind(parserOnIncoming, undefined, | ||
| 503 | + parser.onIncoming = parserOnIncoming.bind(undefined, | ||
| 510 | 504 | server, socket, state); | |
| 511 | 505 | ||
| 512 | 506 | // We are consuming socket, so it won't get any actual data | |
@@ -527,18 +521,18 @@ function connectionListenerInternal(server, socket) { | |||
| 527 | 521 | parser.consume(socket._handle); | |
| 528 | 522 | } | |
| 529 | 523 | parser[kOnExecute] = | |
| 530 | - FunctionPrototypeBind(onParserExecute, undefined, | ||
| 531 | - server, socket, parser, state); | ||
| 524 | + onParserExecute.bind(undefined, | ||
| 525 | + server, socket, parser, state); | ||
| 532 | 526 | ||
| 533 | 527 | parser[kOnTimeout] = | |
| 534 | - FunctionPrototypeBind(onParserTimeout, undefined, | ||
| 535 | - server, socket); | ||
| 528 | + onParserTimeout.bind(undefined, | ||
| 529 | + server, socket); | ||
| 536 | 530 | ||
| 537 | 531 | // When receiving new requests on the same socket (pipelining or keep alive) | |
| 538 | 532 | // make sure the requestTimeout is active. | |
| 539 | 533 | parser[kOnMessageBegin] = | |
| 540 | - FunctionPrototypeBind(setRequestTimeout, undefined, | ||
| 541 | - server, socket); | ||
| 534 | + setRequestTimeout.bind(undefined, | ||
| 535 | + server, socket); | ||
| 542 | 536 | ||
| 543 | 537 | // This protects from DOS attack where an attacker establish the connection | |
| 544 | 538 | // without sending any data on applications where server.timeout is left to | |
@@ -594,7 +588,7 @@ function socketOnClose(socket, state) { | |||
| 594 | 588 | ||
| 595 | 589 | function abortIncoming(incoming) { | |
| 596 | 590 | while (incoming.length) { | |
| 597 | - const req = ArrayPrototypeShift(incoming); | ||
| 591 | + const req = incoming.shift(); | ||
| 598 | 592 | req.destroy(connResetException('aborted')); | |
| 599 | 593 | } | |
| 600 | 594 | // Abort socket._httpMessage ? | |
@@ -606,7 +600,7 @@ function socketOnEnd(server, socket, parser, state) { | |||
| 606 | 600 | if (ret instanceof Error) { | |
| 607 | 601 | debug('parse error'); | |
| 608 | 602 | // socketOnError has additional logic and will call socket.destroy(err). | |
| 609 | - FunctionPrototypeCall(socketOnError, socket, ret); | ||
| 603 | + socketOnError.call(socket, ret); | ||
| 610 | 604 | } else if (!server.httpAllowHalfOpen) { | |
| 611 | 605 | socket.end(); | |
| 612 | 606 | } else if (state.outgoing.length) { | |
@@ -629,7 +623,7 @@ function socketOnData(server, socket, parser, state, d) { | |||
| 629 | 623 | function onRequestTimeout(socket) { | |
| 630 | 624 | socket[kRequestTimeout] = undefined; | |
| 631 | 625 | // socketOnError has additional logic and will call socket.destroy(err). | |
| 632 | - ReflectApply(socketOnError, socket, [new ERR_HTTP_REQUEST_TIMEOUT()]); | ||
| 626 | + socketOnError.call(socket, new ERR_HTTP_REQUEST_TIMEOUT()); | ||
| 633 | 627 | } | |
| 634 | 628 | ||
| 635 | 629 | function onParserExecute(server, socket, parser, state, ret) { | |
@@ -649,7 +643,7 @@ function onParserTimeout(server, socket) { | |||
| 649 | 643 | socket.destroy(); | |
| 650 | 644 | } | |
| 651 | 645 | ||
| 652 | - const noop = FunctionPrototype; | ||
| 646 | + const noop = () => {}; | ||
| 653 | 647 | const badRequestResponse = Buffer.from( | |
| 654 | 648 | `HTTP/1.1 400 ${STATUS_CODES[400]}${CRLF}` + | |
| 655 | 649 | `Connection: close${CRLF}${CRLF}`, 'ascii' | |
@@ -696,7 +690,7 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) { | |||
| 696 | 690 | prepareError(ret, parser, d); | |
| 697 | 691 | ret.rawPacket = d || parser.getCurrentBuffer(); | |
| 698 | 692 | debug('parse error', ret); | |
| 699 | - FunctionPrototypeCall(socketOnError, socket, ret); | ||
| 693 | + socketOnError.call(socket, ret); | ||
| 700 | 694 | } else if (parser.incoming && parser.incoming.upgrade) { | |
| 701 | 695 | // Upgrade or CONNECT | |
| 702 | 696 | const req = parser.incoming; | |
@@ -719,7 +713,7 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) { | |||
| 719 | 713 | const eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade'; | |
| 720 | 714 | if (eventName === 'upgrade' || server.listenerCount(eventName) > 0) { | |
| 721 | 715 | debug('SERVER have listener for %s', eventName); | |
| 722 | - const bodyHead = TypedArrayPrototypeSlice(d, ret, d.length); | ||
| 716 | + const bodyHead = d.slice(ret, d.length); | ||
| 723 | 717 | ||
| 724 | 718 | socket.readableFlowing = null; | |
| 725 | 719 | ||
@@ -738,7 +732,7 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) { | |||
| 738 | 732 | // When receiving new requests on the same socket (pipelining or keep alive) | |
| 739 | 733 | // make sure the requestTimeout is active. | |
| 740 | 734 | parser[kOnMessageBegin] = | |
| 741 | - FunctionPrototypeBind(setRequestTimeout, undefined, server, socket); | ||
| 735 | + setRequestTimeout.bind(undefined, server, socket); | ||
| 742 | 736 | } | |
| 743 | 737 | ||
| 744 | 738 | if (socket._paused && socket.parser) { | |
@@ -802,7 +796,7 @@ function resOnFinish(req, res, socket, state, server) { | |||
| 802 | 796 | // array will be empty. | |
| 803 | 797 | assert(state.incoming.length === 0 || state.incoming[0] === req); | |
| 804 | 798 | ||
| 805 | - ArrayPrototypeShift(state.incoming); | ||
| 799 | + state.incoming.shift(); | ||
| 806 | 800 | ||
| 807 | 801 | // If the user never called req.read(), and didn't pipe() or | |
| 808 | 802 | // .resume() or .on('data'), then we call req._dump() so that the | |
@@ -835,7 +829,7 @@ function resOnFinish(req, res, socket, state, server) { | |||
| 835 | 829 | } | |
| 836 | 830 | } else { | |
| 837 | 831 | // Start sending the next message | |
| 838 | - const m = ArrayPrototypeShift(state.outgoing); | ||
| 832 | + const m = state.outgoing.shift(); | ||
| 839 | 833 | if (m) { | |
| 840 | 834 | m.assignSocket(socket); | |
| 841 | 835 | } | |
@@ -861,7 +855,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) { | |||
| 861 | 855 | return 2; | |
| 862 | 856 | } | |
| 863 | 857 | ||
| 864 | - ArrayPrototypePush(state.incoming, req); | ||
| 858 | + state.incoming.push(req); | ||
| 865 | 859 | ||
| 866 | 860 | // If the writable end isn't consuming, then stop reading | |
| 867 | 861 | // so that we don't become overwhelmed by a flood of | |
@@ -879,8 +873,8 @@ function parserOnIncoming(server, socket, state, req, keepAlive) { | |||
| 879 | 873 | ||
| 880 | 874 | const res = new server[kServerResponse](req); | |
| 881 | 875 | res._keepAliveTimeout = server.keepAliveTimeout; | |
| 882 | - res._onPendingData = FunctionPrototypeBind(updateOutgoingData, undefined, | ||
| 883 | - socket, state); | ||
| 876 | + res._onPendingData = updateOutgoingData.bind(undefined, | ||
| 877 | + socket, state); | ||
| 884 | 878 | ||
| 885 | 879 | res.shouldKeepAlive = keepAlive; | |
| 886 | 880 | DTRACE_HTTP_SERVER_REQUEST(req, socket); | |
@@ -896,16 +890,16 @@ function parserOnIncoming(server, socket, state, req, keepAlive) { | |||
| 896 | 890 | ||
| 897 | 891 | if (socket._httpMessage) { | |
| 898 | 892 | // There are already pending outgoing res, append. | |
| 899 | - ArrayPrototypePush(state.outgoing, res); | ||
| 893 | + state.outgoing.push(res); | ||
| 900 | 894 | } else { | |
| 901 | 895 | res.assignSocket(socket); | |
| 902 | 896 | } | |
| 903 | 897 | ||
| 904 | 898 | // When we're finished writing the response, check if this is the last | |
| 905 | 899 | // response, if so destroy the socket. | |
| 906 | 900 | res.on('finish', | |
| 907 | - FunctionPrototypeBind(resOnFinish, undefined, | ||
| 908 | - req, res, socket, state, server)); | ||
| 901 | + resOnFinish.bind(undefined, | ||
| 902 | + req, res, socket, state, server)); | ||
| 909 | 903 | ||
| 910 | 904 | if (req.headers.expect !== undefined && | |
| 911 | 905 | (req.httpVersionMajor === 1 && req.httpVersionMinor === 1)) { | |
@@ -977,8 +971,8 @@ function unconsume(parser, socket) { | |||
| 977 | 971 | ||
| 978 | 972 | function generateSocketListenerWrapper(originalFnName) { | |
| 979 | 973 | return function socketListenerWrap(ev, fn) { | |
| 980 | - const res = ReflectApply(net.Socket.prototype[originalFnName], this, | ||
| 981 | - [ev, fn]); | ||
| 974 | + const res = net.Socket.prototype[originalFnName].call(this, | ||
| 975 | + ev, fn); | ||
| 982 | 976 | if (!this.parser) { | |
| 983 | 977 | this.on = net.Socket.prototype.on; | |
| 984 | 978 | this.addListener = net.Socket.prototype.addListener; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments