| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ee40a00 commit ac7beba
117 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 | - Object: { | ||
| 26 | - setPrototypeOf: ObjectSetPrototypeOf, | ||
| 27 | - keys: ObjectKeys, | ||
| 28 | - values: ObjectValues | ||
| 29 | - } | ||
| 25 | + ObjectKeys, | ||
| 26 | + ObjectSetPrototypeOf, | ||
| 27 | + ObjectValues, | ||
| 30 | 28 | } = primordials; | |
| 31 | 29 | ||
| 32 | 30 | const net = require('net'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,11 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | - const { Object } = primordials; | ||
| 24 | + const { | ||
| 25 | + ObjectAssign, | ||
| 26 | + ObjectKeys, | ||
| 27 | + ObjectSetPrototypeOf, | ||
| 28 | + } = primordials; | ||
| 25 | 29 | ||
| 26 | 30 | const net = require('net'); | |
| 27 | 31 | const url = require('url'); | |
@@ -108,7 +112,7 @@ function ClientRequest(input, options, cb) { | |||
| 108 | 112 | cb = options; | |
| 109 | 113 | options = input || {}; | |
| 110 | 114 | } else { | |
| 111 | - options = Object.assign(input || {}, options); | ||
| 115 | + options = ObjectAssign(input || {}, options); | ||
| 112 | 116 | } | |
| 113 | 117 | ||
| 114 | 118 | let agent = options.agent; | |
@@ -217,7 +221,7 @@ function ClientRequest(input, options, cb) { | |||
| 217 | 221 | const headersArray = Array.isArray(options.headers); | |
| 218 | 222 | if (!headersArray) { | |
| 219 | 223 | if (options.headers) { | |
| 220 | - const keys = Object.keys(options.headers); | ||
| 224 | + const keys = ObjectKeys(options.headers); | ||
| 221 | 225 | for (let i = 0; i < keys.length; i++) { | |
| 222 | 226 | const key = keys[i]; | |
| 223 | 227 | this.setHeader(key, options.headers[key]); | |
@@ -296,8 +300,8 @@ function ClientRequest(input, options, cb) { | |||
| 296 | 300 | ||
| 297 | 301 | this._deferToConnect(null, null, () => this._flush()); | |
| 298 | 302 | } | |
| 299 | - Object.setPrototypeOf(ClientRequest.prototype, OutgoingMessage.prototype); | ||
| 300 | - Object.setPrototypeOf(ClientRequest, OutgoingMessage); | ||
| 303 | + ObjectSetPrototypeOf(ClientRequest.prototype, OutgoingMessage.prototype); | ||
| 304 | + ObjectSetPrototypeOf(ClientRequest, OutgoingMessage); | ||
| 301 | 305 | ||
| 302 | 306 | ClientRequest.prototype._finish = function _finish() { | |
| 303 | 307 | DTRACE_HTTP_CLIENT_REQUEST(this, this.connection); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,9 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | - const { Math } = primordials; | ||
| 24 | + const { | ||
| 25 | + MathMin, | ||
| 26 | + } = primordials; | ||
| 25 | 27 | const { setImmediate } = require('timers'); | |
| 26 | 28 | ||
| 27 | 29 | const { getOptionValue } = require('internal/options'); | |
@@ -100,7 +102,7 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method, | |||
| 100 | 102 | ||
| 101 | 103 | // If parser.maxHeaderPairs <= 0 assume that there's no limit. | |
| 102 | 104 | if (parser.maxHeaderPairs > 0) | |
| 103 | - n = Math.min(n, parser.maxHeaderPairs); | ||
| 105 | + n = MathMin(n, parser.maxHeaderPairs); | ||
| 104 | 106 | ||
| 105 | 107 | incoming._addHeaderLines(headers, n); | |
| 106 | 108 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,9 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | - const { Object } = primordials; | ||
| 24 | + const { | ||
| 25 | + ObjectSetPrototypeOf, | ||
| 26 | + } = primordials; | ||
| 25 | 27 | ||
| 26 | 28 | const Stream = require('stream'); | |
| 27 | 29 | ||
@@ -81,8 +83,8 @@ function IncomingMessage(socket) { | |||
| 81 | 83 | // read by the user, so there's no point continuing to handle it. | |
| 82 | 84 | this._dumped = false; | |
| 83 | 85 | } | |
| 84 | - Object.setPrototypeOf(IncomingMessage.prototype, Stream.Readable.prototype); | ||
| 85 | - Object.setPrototypeOf(IncomingMessage, Stream.Readable); | ||
| 86 | + ObjectSetPrototypeOf(IncomingMessage.prototype, Stream.Readable.prototype); | ||
| 87 | + ObjectSetPrototypeOf(IncomingMessage, Stream.Readable); | ||
| 86 | 88 | ||
| 87 | 89 | IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) { | |
| 88 | 90 | if (callback) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,13 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | - const { Object, ObjectPrototype } = primordials; | ||
| 24 | + const { | ||
| 25 | + ObjectCreate, | ||
| 26 | + ObjectDefineProperty, | ||
| 27 | + ObjectKeys, | ||
| 28 | + ObjectPrototypeHasOwnProperty, | ||
| 29 | + ObjectSetPrototypeOf, | ||
| 30 | + } = primordials; | ||
| 25 | 31 | ||
| 26 | 32 | const { getDefaultHighWaterMark } = require('internal/streams/state'); | |
| 27 | 33 | const assert = require('internal/assert'); | |
@@ -109,10 +115,10 @@ function OutgoingMessage() { | |||
| 109 | 115 | ||
| 110 | 116 | this._onPendingData = noopPendingOutput; | |
| 111 | 117 | } | |
| 112 | - Object.setPrototypeOf(OutgoingMessage.prototype, Stream.prototype); | ||
| 113 | - Object.setPrototypeOf(OutgoingMessage, Stream); | ||
| 118 | + ObjectSetPrototypeOf(OutgoingMessage.prototype, Stream.prototype); | ||
| 119 | + ObjectSetPrototypeOf(OutgoingMessage, Stream); | ||
| 114 | 120 | ||
| 115 | - Object.defineProperty(OutgoingMessage.prototype, 'writableFinished', { | ||
| 121 | + ObjectDefineProperty(OutgoingMessage.prototype, 'writableFinished', { | ||
| 116 | 122 | get() { | |
| 117 | 123 | return ( | |
| 118 | 124 | this.finished && | |
@@ -122,41 +128,41 @@ Object.defineProperty(OutgoingMessage.prototype, 'writableFinished', { | |||
| 122 | 128 | } | |
| 123 | 129 | }); | |
| 124 | 130 | ||
| 125 | - Object.defineProperty(OutgoingMessage.prototype, 'writableObjectMode', { | ||
| 131 | + ObjectDefineProperty(OutgoingMessage.prototype, 'writableObjectMode', { | ||
| 126 | 132 | get() { | |
| 127 | 133 | return false; | |
| 128 | 134 | } | |
| 129 | 135 | }); | |
| 130 | 136 | ||
| 131 | - Object.defineProperty(OutgoingMessage.prototype, 'writableLength', { | ||
| 137 | + ObjectDefineProperty(OutgoingMessage.prototype, 'writableLength', { | ||
| 132 | 138 | get() { | |
| 133 | 139 | return this.outputSize + (this.socket ? this.socket.writableLength : 0); | |
| 134 | 140 | } | |
| 135 | 141 | }); | |
| 136 | 142 | ||
| 137 | - Object.defineProperty(OutgoingMessage.prototype, 'writableHighWaterMark', { | ||
| 143 | + ObjectDefineProperty(OutgoingMessage.prototype, 'writableHighWaterMark', { | ||
| 138 | 144 | get() { | |
| 139 | 145 | return this.socket ? this.socket.writableHighWaterMark : HIGH_WATER_MARK; | |
| 140 | 146 | } | |
| 141 | 147 | }); | |
| 142 | 148 | ||
| 143 | - Object.defineProperty(OutgoingMessage.prototype, 'writableCorked', { | ||
| 149 | + ObjectDefineProperty(OutgoingMessage.prototype, 'writableCorked', { | ||
| 144 | 150 | get() { | |
| 145 | 151 | const corked = this.socket ? this.socket.writableCorked : 0; | |
| 146 | 152 | return corked + this[kCorked]; | |
| 147 | 153 | } | |
| 148 | 154 | }); | |
| 149 | 155 | ||
| 150 | - Object.defineProperty(OutgoingMessage.prototype, '_headers', { | ||
| 156 | + ObjectDefineProperty(OutgoingMessage.prototype, '_headers', { | ||
| 151 | 157 | get: internalUtil.deprecate(function() { | |
| 152 | 158 | return this.getHeaders(); | |
| 153 | 159 | }, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'), | |
| 154 | 160 | set: internalUtil.deprecate(function(val) { | |
| 155 | 161 | if (val == null) { | |
| 156 | 162 | this[kOutHeaders] = null; | |
| 157 | 163 | } else if (typeof val === 'object') { | |
| 158 | - const headers = this[kOutHeaders] = Object.create(null); | ||
| 159 | - const keys = Object.keys(val); | ||
| 164 | + const headers = this[kOutHeaders] = ObjectCreate(null); | ||
| 165 | + const keys = ObjectKeys(val); | ||
| 160 | 166 | for (var i = 0; i < keys.length; ++i) { | |
| 161 | 167 | const name = keys[i]; | |
| 162 | 168 | headers[name.toLowerCase()] = [name, val[name]]; | |
@@ -165,12 +171,12 @@ Object.defineProperty(OutgoingMessage.prototype, '_headers', { | |||
| 165 | 171 | }, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066') | |
| 166 | 172 | }); | |
| 167 | 173 | ||
| 168 | - Object.defineProperty(OutgoingMessage.prototype, '_headerNames', { | ||
| 174 | + ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', { | ||
| 169 | 175 | get: internalUtil.deprecate(function() { | |
| 170 | 176 | const headers = this[kOutHeaders]; | |
| 171 | 177 | if (headers !== null) { | |
| 172 | - const out = Object.create(null); | ||
| 173 | - const keys = Object.keys(headers); | ||
| 178 | + const out = ObjectCreate(null); | ||
| 179 | + const keys = ObjectKeys(headers); | ||
| 174 | 180 | for (var i = 0; i < keys.length; ++i) { | |
| 175 | 181 | const key = keys[i]; | |
| 176 | 182 | const val = headers[key][0]; | |
@@ -185,7 +191,7 @@ Object.defineProperty(OutgoingMessage.prototype, '_headerNames', { | |||
| 185 | 191 | const headers = this[kOutHeaders]; | |
| 186 | 192 | if (!headers) | |
| 187 | 193 | return; | |
| 188 | - const keys = Object.keys(val); | ||
| 194 | + const keys = ObjectKeys(val); | ||
| 189 | 195 | for (var i = 0; i < keys.length; ++i) { | |
| 190 | 196 | const header = headers[keys[i]]; | |
| 191 | 197 | if (header) | |
@@ -205,7 +211,7 @@ OutgoingMessage.prototype._renderHeaders = function _renderHeaders() { | |||
| 205 | 211 | const headers = {}; | |
| 206 | 212 | ||
| 207 | 213 | if (headersMap !== null) { | |
| 208 | - const keys = Object.keys(headersMap); | ||
| 214 | + const keys = ObjectKeys(headersMap); | ||
| 209 | 215 | for (var i = 0, l = keys.length; i < l; i++) { | |
| 210 | 216 | const key = keys[i]; | |
| 211 | 217 | headers[headersMap[key][0]] = headersMap[key][1]; | |
@@ -350,7 +356,7 @@ function _storeHeader(firstLine, headers) { | |||
| 350 | 356 | } | |
| 351 | 357 | } else { | |
| 352 | 358 | for (const key in headers) { | |
| 353 | - if (ObjectPrototype.hasOwnProperty(headers, key)) { | ||
| 359 | + if (ObjectPrototypeHasOwnProperty(headers, key)) { | ||
| 354 | 360 | processHeader(this, state, key, headers[key], true); | |
| 355 | 361 | } | |
| 356 | 362 | } | |
@@ -511,7 +517,7 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) { | |||
| 511 | 517 | ||
| 512 | 518 | let headers = this[kOutHeaders]; | |
| 513 | 519 | if (headers === null) | |
| 514 | - this[kOutHeaders] = headers = Object.create(null); | ||
| 520 | + this[kOutHeaders] = headers = ObjectCreate(null); | ||
| 515 | 521 | ||
| 516 | 522 | headers[name.toLowerCase()] = [name, value]; | |
| 517 | 523 | }; | |
@@ -531,16 +537,16 @@ OutgoingMessage.prototype.getHeader = function getHeader(name) { | |||
| 531 | 537 | ||
| 532 | 538 | // Returns an array of the names of the current outgoing headers. | |
| 533 | 539 | OutgoingMessage.prototype.getHeaderNames = function getHeaderNames() { | |
| 534 | - return this[kOutHeaders] !== null ? Object.keys(this[kOutHeaders]) : []; | ||
| 540 | + return this[kOutHeaders] !== null ? ObjectKeys(this[kOutHeaders]) : []; | ||
| 535 | 541 | }; | |
| 536 | 542 | ||
| 537 | 543 | ||
| 538 | 544 | // Returns a shallow copy of the current outgoing headers. | |
| 539 | 545 | OutgoingMessage.prototype.getHeaders = function getHeaders() { | |
| 540 | 546 | const headers = this[kOutHeaders]; | |
| 541 | - const ret = Object.create(null); | ||
| 547 | + const ret = ObjectCreate(null); | ||
| 542 | 548 | if (headers) { | |
| 543 | - const keys = Object.keys(headers); | ||
| 549 | + const keys = ObjectKeys(headers); | ||
| 544 | 550 | for (var i = 0; i < keys.length; ++i) { | |
| 545 | 551 | const key = keys[i]; | |
| 546 | 552 | const val = headers[key][1]; | |
@@ -592,13 +598,13 @@ OutgoingMessage.prototype._implicitHeader = function _implicitHeader() { | |||
| 592 | 598 | this.emit('error', new ERR_METHOD_NOT_IMPLEMENTED('_implicitHeader()')); | |
| 593 | 599 | }; | |
| 594 | 600 | ||
| 595 | - Object.defineProperty(OutgoingMessage.prototype, 'headersSent', { | ||
| 601 | + ObjectDefineProperty(OutgoingMessage.prototype, 'headersSent', { | ||
| 596 | 602 | configurable: true, | |
| 597 | 603 | enumerable: true, | |
| 598 | 604 | get: function() { return !!this._header; } | |
| 599 | 605 | }); | |
| 600 | 606 | ||
| 601 | - Object.defineProperty(OutgoingMessage.prototype, 'writableEnded', { | ||
| 607 | + ObjectDefineProperty(OutgoingMessage.prototype, 'writableEnded', { | ||
| 602 | 608 | get: function() { return this.finished; } | |
| 603 | 609 | }); | |
| 604 | 610 | ||
@@ -679,7 +685,7 @@ function connectionCorkNT(conn) { | |||
| 679 | 685 | ||
| 680 | 686 | OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { | |
| 681 | 687 | this._trailer = ''; | |
| 682 | - const keys = Object.keys(headers); | ||
| 688 | + const keys = ObjectKeys(headers); | ||
| 683 | 689 | const isArray = Array.isArray(headers); | |
| 684 | 690 | var field, value; | |
| 685 | 691 | for (var i = 0, l = keys.length; i < l; i++) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,10 +22,8 @@ | |||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | - Object: { | ||
| 26 | - setPrototypeOf: ObjectSetPrototypeOf, | ||
| 27 | - keys: ObjectKeys, | ||
| 28 | - } | ||
| 25 | + ObjectKeys, | ||
| 26 | + ObjectSetPrototypeOf, | ||
| 29 | 27 | } = primordials; | |
| 30 | 28 | ||
| 31 | 29 | const net = require('net'); | |
@@ -265,7 +263,7 @@ function writeHead(statusCode, reason, obj) { | |||
| 265 | 263 | let k; | |
| 266 | 264 | if (obj) { | |
| 267 | 265 | const keys = ObjectKeys(obj); | |
| 268 | - for (var i = 0; i < keys.length; i++) { | ||
| 266 | + for (let i = 0; i < keys.length; i++) { | ||
| 269 | 267 | k = keys[i]; | |
| 270 | 268 | if (k) this.setHeader(k, obj[k]); | |
| 271 | 269 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,19 +26,23 @@ | |||
| 26 | 26 | ||
| 27 | 27 | 'use strict'; | |
| 28 | 28 | ||
| 29 | - const { Object } = primordials; | ||
| 29 | + const { | ||
| 30 | + ObjectDefineProperty, | ||
| 31 | + ObjectKeys, | ||
| 32 | + ObjectSetPrototypeOf, | ||
| 33 | + } = primordials; | ||
| 30 | 34 | ||
| 31 | 35 | module.exports = Duplex; | |
| 32 | 36 | ||
| 33 | 37 | const Readable = require('_stream_readable'); | |
| 34 | 38 | const Writable = require('_stream_writable'); | |
| 35 | 39 | ||
| 36 | - Object.setPrototypeOf(Duplex.prototype, Readable.prototype); | ||
| 37 | - Object.setPrototypeOf(Duplex, Readable); | ||
| 40 | + ObjectSetPrototypeOf(Duplex.prototype, Readable.prototype); | ||
| 41 | + ObjectSetPrototypeOf(Duplex, Readable); | ||
| 38 | 42 | ||
| 39 | 43 | { | |
| 40 | 44 | // Allow the keys array to be GC'ed. | |
| 41 | - const keys = Object.keys(Writable.prototype); | ||
| 45 | + const keys = ObjectKeys(Writable.prototype); | ||
| 42 | 46 | for (let v = 0; v < keys.length; v++) { | |
| 43 | 47 | const method = keys[v]; | |
| 44 | 48 | if (!Duplex.prototype[method]) | |
@@ -68,7 +72,7 @@ function Duplex(options) { | |||
| 68 | 72 | } | |
| 69 | 73 | } | |
| 70 | 74 | ||
| 71 | - Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { | ||
| 75 | + ObjectDefineProperty(Duplex.prototype, 'writableHighWaterMark', { | ||
| 72 | 76 | // Making it explicit this property is not enumerable | |
| 73 | 77 | // because otherwise some prototype manipulation in | |
| 74 | 78 | // userland will fail | |
@@ -78,7 +82,7 @@ Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { | |||
| 78 | 82 | } | |
| 79 | 83 | }); | |
| 80 | 84 | ||
| 81 | - Object.defineProperty(Duplex.prototype, 'writableBuffer', { | ||
| 85 | + ObjectDefineProperty(Duplex.prototype, 'writableBuffer', { | ||
| 82 | 86 | // Making it explicit this property is not enumerable | |
| 83 | 87 | // because otherwise some prototype manipulation in | |
| 84 | 88 | // userland will fail | |
@@ -88,7 +92,7 @@ Object.defineProperty(Duplex.prototype, 'writableBuffer', { | |||
| 88 | 92 | } | |
| 89 | 93 | }); | |
| 90 | 94 | ||
| 91 | - Object.defineProperty(Duplex.prototype, 'writableLength', { | ||
| 95 | + ObjectDefineProperty(Duplex.prototype, 'writableLength', { | ||
| 92 | 96 | // Making it explicit this property is not enumerable | |
| 93 | 97 | // because otherwise some prototype manipulation in | |
| 94 | 98 | // userland will fail | |
@@ -98,7 +102,7 @@ Object.defineProperty(Duplex.prototype, 'writableLength', { | |||
| 98 | 102 | } | |
| 99 | 103 | }); | |
| 100 | 104 | ||
| 101 | - Object.defineProperty(Duplex.prototype, 'writableFinished', { | ||
| 105 | + ObjectDefineProperty(Duplex.prototype, 'writableFinished', { | ||
| 102 | 106 | // Making it explicit this property is not enumerable | |
| 103 | 107 | // because otherwise some prototype manipulation in | |
| 104 | 108 | // userland will fail | |
@@ -108,7 +112,7 @@ Object.defineProperty(Duplex.prototype, 'writableFinished', { | |||
| 108 | 112 | } | |
| 109 | 113 | }); | |
| 110 | 114 | ||
| 111 | - Object.defineProperty(Duplex.prototype, 'writableCorked', { | ||
| 115 | + ObjectDefineProperty(Duplex.prototype, 'writableCorked', { | ||
| 112 | 116 | // Making it explicit this property is not enumerable | |
| 113 | 117 | // because otherwise some prototype manipulation in | |
| 114 | 118 | // userland will fail | |
@@ -118,7 +122,7 @@ Object.defineProperty(Duplex.prototype, 'writableCorked', { | |||
| 118 | 122 | } | |
| 119 | 123 | }); | |
| 120 | 124 | ||
| 121 | - Object.defineProperty(Duplex.prototype, 'writableEnded', { | ||
| 125 | + ObjectDefineProperty(Duplex.prototype, 'writableEnded', { | ||
| 122 | 126 | // Making it explicit this property is not enumerable | |
| 123 | 127 | // because otherwise some prototype manipulation in | |
| 124 | 128 | // userland will fail | |
@@ -143,7 +147,7 @@ function onEndNT(self) { | |||
| 143 | 147 | self.end(); | |
| 144 | 148 | } | |
| 145 | 149 | ||
| 146 | - Object.defineProperty(Duplex.prototype, 'destroyed', { | ||
| 150 | + ObjectDefineProperty(Duplex.prototype, 'destroyed', { | ||
| 147 | 151 | // Making it explicit this property is not enumerable | |
| 148 | 152 | // because otherwise some prototype manipulation in | |
| 149 | 153 | // userland will fail | |
| Back | FazBrowse Home | New Git URL |
0 commit comments