GeezerVison is showing github.com — lib: use null-prototype objects for property descriptors · nodejs/node@b864460
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/_http_incoming.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -98,6 +98,7 @@ ObjectSetPrototypeOf(IncomingMessage.prototype, Readable.prototype); | 98 | 98 | ObjectSetPrototypeOf(IncomingMessage, Readable); | 99 | 99 |
| 100 | 100 | ObjectDefineProperty(IncomingMessage.prototype, 'connection', { | | 101 | + __proto__: null, | 101 | 102 | get: function() { | 102 | 103 | return this.socket; | 103 | 104 | }, | @@ -107,6 +108,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'connection', { | 107 | 108 | }); | 108 | 109 |
| 109 | 110 | ObjectDefineProperty(IncomingMessage.prototype, 'headers', { | | 111 | + __proto__: null, | 110 | 112 | get: function() { | 111 | 113 | if (!this[kHeaders]) { | 112 | 114 | this[kHeaders] = {}; | @@ -126,6 +128,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headers', { | 126 | 128 | }); | 127 | 129 |
| 128 | 130 | ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', { | | 131 | + __proto__: null, | 129 | 132 | get: function() { | 130 | 133 | if (!this[kHeadersDistinct]) { | 131 | 134 | this[kHeadersDistinct] = {}; | @@ -145,6 +148,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', { | 145 | 148 | }); | 146 | 149 |
| 147 | 150 | ObjectDefineProperty(IncomingMessage.prototype, 'trailers', { | | 151 | + __proto__: null, | 148 | 152 | get: function() { | 149 | 153 | if (!this[kTrailers]) { | 150 | 154 | this[kTrailers] = {}; | @@ -164,6 +168,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'trailers', { | 164 | 168 | }); | 165 | 169 |
| 166 | 170 | ObjectDefineProperty(IncomingMessage.prototype, 'trailersDistinct', { | | 171 | + __proto__: null, | 167 | 172 | get: function() { | 168 | 173 | if (!this[kTrailersDistinct]) { | 169 | 174 | this[kTrailersDistinct] = {}; | |
Collapse file Copy file name to clipboardExpand all lines: lib/_http_outgoing.js +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -145,6 +145,7 @@ ObjectSetPrototypeOf(OutgoingMessage.prototype, Stream.prototype); | 145 | 145 | ObjectSetPrototypeOf(OutgoingMessage, Stream); | 146 | 146 |
| 147 | 147 | ObjectDefineProperty(OutgoingMessage.prototype, 'writableFinished', { | | 148 | + __proto__: null, | 148 | 149 | get() { | 149 | 150 | return ( | 150 | 151 | this.finished && | @@ -155,31 +156,36 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'writableFinished', { | 155 | 156 | }); | 156 | 157 |
| 157 | 158 | ObjectDefineProperty(OutgoingMessage.prototype, 'writableObjectMode', { | | 159 | + __proto__: null, | 158 | 160 | get() { | 159 | 161 | return false; | 160 | 162 | } | 161 | 163 | }); | 162 | 164 |
| 163 | 165 | ObjectDefineProperty(OutgoingMessage.prototype, 'writableLength', { | | 166 | + __proto__: null, | 164 | 167 | get() { | 165 | 168 | return this.outputSize + (this.socket ? this.socket.writableLength : 0); | 166 | 169 | } | 167 | 170 | }); | 168 | 171 |
| 169 | 172 | ObjectDefineProperty(OutgoingMessage.prototype, 'writableHighWaterMark', { | | 173 | + __proto__: null, | 170 | 174 | get() { | 171 | 175 | return this.socket ? this.socket.writableHighWaterMark : HIGH_WATER_MARK; | 172 | 176 | } | 173 | 177 | }); | 174 | 178 |
| 175 | 179 | ObjectDefineProperty(OutgoingMessage.prototype, 'writableCorked', { | | 180 | + __proto__: null, | 176 | 181 | get() { | 177 | 182 | const corked = this.socket ? this.socket.writableCorked : 0; | 178 | 183 | return corked + this[kCorked]; | 179 | 184 | } | 180 | 185 | }); | 181 | 186 |
| 182 | 187 | ObjectDefineProperty(OutgoingMessage.prototype, '_headers', { | | 188 | + __proto__: null, | 183 | 189 | get: internalUtil.deprecate(function() { | 184 | 190 | return this.getHeaders(); | 185 | 191 | }, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'), | @@ -200,6 +206,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headers', { | 200 | 206 | }); | 201 | 207 |
| 202 | 208 | ObjectDefineProperty(OutgoingMessage.prototype, 'connection', { | | 209 | + __proto__: null, | 203 | 210 | get: function() { | 204 | 211 | return this.socket; | 205 | 212 | }, | @@ -209,6 +216,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'connection', { | 209 | 216 | }); | 210 | 217 |
| 211 | 218 | ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', { | | 219 | + __proto__: null, | 212 | 220 | get: internalUtil.deprecate(function() { | 213 | 221 | const headers = this[kOutHeaders]; | 214 | 222 | if (headers !== null) { | @@ -731,16 +739,19 @@ OutgoingMessage.prototype._implicitHeader = function _implicitHeader() { | 731 | 739 | }; | 732 | 740 |
| 733 | 741 | ObjectDefineProperty(OutgoingMessage.prototype, 'headersSent', { | | 742 | + __proto__: null, | 734 | 743 | configurable: true, | 735 | 744 | enumerable: true, | 736 | 745 | get: function() { return !!this._header; } | 737 | 746 | }); | 738 | 747 |
| 739 | 748 | ObjectDefineProperty(OutgoingMessage.prototype, 'writableEnded', { | | 749 | + __proto__: null, | 740 | 750 | get: function() { return this.finished; } | 741 | 751 | }); | 742 | 752 |
| 743 | 753 | ObjectDefineProperty(OutgoingMessage.prototype, 'writableNeedDrain', { | | 754 | + __proto__: null, | 744 | 755 | get: function() { | 745 | 756 | return !this.destroyed && !this.finished && this[kNeedDrain]; | 746 | 757 | } | |
Collapse file Copy file name to clipboardExpand all lines: lib/_tls_wrap.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -631,6 +631,7 @@ TLSSocket.prototype._wrapHandle = function(wrap) { | 631 | 631 | // Ref: https://github.com/nodejs/node/commit/f7620fb96d339f704932f9bb9a0dceb9952df2d4 | 632 | 632 | function defineHandleReading(socket, handle) { | 633 | 633 | ObjectDefineProperty(handle, 'reading', { | | 634 | + __proto__: null, | 634 | 635 | get: () => { | 635 | 636 | return socket[kRes].reading; | 636 | 637 | }, | |
Collapse file Copy file name to clipboardExpand all lines: lib/async_hooks.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -238,12 +238,14 @@ class AsyncResource { | 238 | 238 | } | 239 | 239 | ObjectDefineProperties(bound, { | 240 | 240 | 'length': { | | 241 | + __proto__: null, | 241 | 242 | configurable: true, | 242 | 243 | enumerable: false, | 243 | 244 | value: fn.length, | 244 | 245 | writable: false, | 245 | 246 | }, | 246 | 247 | 'asyncResource': { | | 248 | + __proto__: null, | 247 | 249 | configurable: true, | 248 | 250 | enumerable: true, | 249 | 251 | value: this, | |
Collapse file Copy file name to clipboardExpand all lines: lib/buffer.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -282,6 +282,7 @@ function Buffer(arg, encodingOrOffset, length) { | 282 | 282 | } | 283 | 283 |
| 284 | 284 | ObjectDefineProperty(Buffer, SymbolSpecies, { | | 285 | + __proto__: null, | 285 | 286 | enumerable: false, | 286 | 287 | configurable: true, | 287 | 288 | get() { return FastBuffer; } | @@ -756,6 +757,7 @@ Buffer.byteLength = byteLength; | 756 | 757 |
| 757 | 758 | // For backwards compatibility. | 758 | 759 | ObjectDefineProperty(Buffer.prototype, 'parent', { | | 760 | + __proto__: null, | 759 | 761 | enumerable: true, | 760 | 762 | get() { | 761 | 763 | if (!(this instanceof Buffer)) | @@ -764,6 +766,7 @@ ObjectDefineProperty(Buffer.prototype, 'parent', { | 764 | 766 | } | 765 | 767 | }); | 766 | 768 | ObjectDefineProperty(Buffer.prototype, 'offset', { | | 769 | + __proto__: null, | 767 | 770 | enumerable: true, | 768 | 771 | get() { | 769 | 772 | if (!(this instanceof Buffer)) | @@ -1302,11 +1305,13 @@ module.exports = { | 1302 | 1305 |
| 1303 | 1306 | ObjectDefineProperties(module.exports, { | 1304 | 1307 | constants: { | | 1308 | + __proto__: null, | 1305 | 1309 | configurable: false, | 1306 | 1310 | enumerable: true, | 1307 | 1311 | value: constants | 1308 | 1312 | }, | 1309 | 1313 | INSPECT_MAX_BYTES: { | | 1314 | + __proto__: null, | 1310 | 1315 | configurable: true, | 1311 | 1316 | enumerable: true, | 1312 | 1317 | get() { return INSPECT_MAX_BYTES; }, | |
Collapse file Copy file name to clipboardExpand all lines: lib/child_process.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -243,6 +243,7 @@ const customPromiseExecFunction = (orig) => { | 243 | 243 | }; | 244 | 244 |
| 245 | 245 | ObjectDefineProperty(exec, promisify.custom, { | | 246 | + __proto__: null, | 246 | 247 | enumerable: false, | 247 | 248 | value: customPromiseExecFunction(exec) | 248 | 249 | }); | @@ -486,6 +487,7 @@ function execFile(file, args = [], options, callback) { | 486 | 487 | } | 487 | 488 |
| 488 | 489 | ObjectDefineProperty(execFile, promisify.custom, { | | 490 | + __proto__: null, | 489 | 491 | enumerable: false, | 490 | 492 | value: customPromiseExecFunction(execFile) | 491 | 493 | }); | |
Collapse file Copy file name to clipboardExpand all lines: lib/crypto.js +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -259,9 +259,11 @@ function getRandomValues(array) { | 259 | 259 | } | 260 | 260 |
| 261 | 261 | ObjectDefineProperty(constants, 'defaultCipherList', { | | 262 | + __proto__: null, | 262 | 263 | get() { | 263 | 264 | const value = getOptionValue('--tls-cipher-list'); | 264 | 265 | ObjectDefineProperty(this, 'defaultCipherList', { | | 266 | + __proto__: null, | 265 | 267 | writable: true, | 266 | 268 | configurable: true, | 267 | 269 | enumerable: true, | @@ -271,6 +273,7 @@ ObjectDefineProperty(constants, 'defaultCipherList', { | 271 | 273 | }, | 272 | 274 | set(val) { | 273 | 275 | ObjectDefineProperty(this, 'defaultCipherList', { | | 276 | + __proto__: null, | 274 | 277 | writable: true, | 275 | 278 | configurable: true, | 276 | 279 | enumerable: true, | @@ -299,6 +302,7 @@ function getRandomBytesAlias(key) { | 299 | 302 | this, | 300 | 303 | key, | 301 | 304 | { | | 305 | + __proto__: null, | 302 | 306 | enumerable: false, | 303 | 307 | configurable: true, | 304 | 308 | writable: true, | @@ -312,6 +316,7 @@ function getRandomBytesAlias(key) { | 312 | 316 | this, | 313 | 317 | key, | 314 | 318 | { | | 319 | + __proto__: null, | 315 | 320 | enumerable: true, | 316 | 321 | configurable: true, | 317 | 322 | writable: true, | @@ -324,21 +329,25 @@ function getRandomBytesAlias(key) { | 324 | 329 |
| 325 | 330 | ObjectDefineProperties(module.exports, { | 326 | 331 | createCipher: { | | 332 | + __proto__: null, | 327 | 333 | enumerable: false, | 328 | 334 | value: deprecate(createCipher, | 329 | 335 | 'crypto.createCipher is deprecated.', 'DEP0106') | 330 | 336 | }, | 331 | 337 | createDecipher: { | | 338 | + __proto__: null, | 332 | 339 | enumerable: false, | 333 | 340 | value: deprecate(createDecipher, | 334 | 341 | 'crypto.createDecipher is deprecated.', 'DEP0106') | 335 | 342 | }, | 336 | 343 | // crypto.fips is deprecated. DEP0093. Use crypto.getFips()/crypto.setFips() | 337 | 344 | fips: { | | 345 | + __proto__: null, | 338 | 346 | get: getFips, | 339 | 347 | set: setFips, | 340 | 348 | }, | 341 | 349 | DEFAULT_ENCODING: { | | 350 | + __proto__: null, | 342 | 351 | enumerable: false, | 343 | 352 | configurable: true, | 344 | 353 | get: deprecate(getDefaultEncoding, | @@ -347,26 +356,30 @@ ObjectDefineProperties(module.exports, { | 347 | 356 | 'crypto.DEFAULT_ENCODING is deprecated.', 'DEP0091') | 348 | 357 | }, | 349 | 358 | constants: { | | 359 | + __proto__: null, | 350 | 360 | configurable: false, | 351 | 361 | enumerable: true, | 352 | 362 | value: constants | 353 | 363 | }, | 354 | 364 |
| 355 | 365 | webcrypto: { | | 366 | + __proto__: null, | 356 | 367 | configurable: false, | 357 | 368 | enumerable: true, | 358 | 369 | get() { return lazyWebCrypto().crypto; }, | 359 | 370 | set: undefined, | 360 | 371 | }, | 361 | 372 |
| 362 | 373 | subtle: { | | 374 | + __proto__: null, | 363 | 375 | configurable: false, | 364 | 376 | enumerable: true, | 365 | 377 | get() { return lazyWebCrypto().crypto.subtle; }, | 366 | 378 | set: undefined, | 367 | 379 | }, | 368 | 380 |
| 369 | 381 | getRandomValues: { | | 382 | + __proto__: null, | 370 | 383 | configurable: false, | 371 | 384 | enumerable: true, | 372 | 385 | get: () => getRandomValues, | |
Collapse file Copy file name to clipboardExpand all lines: lib/dgram.js +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -971,6 +971,7 @@ Socket.prototype.getSendBufferSize = function() { | 971 | 971 |
| 972 | 972 | // Deprecated private APIs. | 973 | 973 | ObjectDefineProperty(Socket.prototype, '_handle', { | | 974 | + __proto__: null, | 974 | 975 | get: deprecate(function() { | 975 | 976 | return this[kStateSymbol].handle; | 976 | 977 | }, 'Socket.prototype._handle is deprecated', 'DEP0112'), | @@ -981,6 +982,7 @@ ObjectDefineProperty(Socket.prototype, '_handle', { | 981 | 982 |
| 982 | 983 |
| 983 | 984 | ObjectDefineProperty(Socket.prototype, '_receiving', { | | 985 | + __proto__: null, | 984 | 986 | get: deprecate(function() { | 985 | 987 | return this[kStateSymbol].receiving; | 986 | 988 | }, 'Socket.prototype._receiving is deprecated', 'DEP0112'), | @@ -991,6 +993,7 @@ ObjectDefineProperty(Socket.prototype, '_receiving', { | 991 | 993 |
| 992 | 994 |
| 993 | 995 | ObjectDefineProperty(Socket.prototype, '_bindState', { | | 996 | + __proto__: null, | 994 | 997 | get: deprecate(function() { | 995 | 998 | return this[kStateSymbol].bindState; | 996 | 999 | }, 'Socket.prototype._bindState is deprecated', 'DEP0112'), | @@ -1001,6 +1004,7 @@ ObjectDefineProperty(Socket.prototype, '_bindState', { | 1001 | 1004 |
| 1002 | 1005 |
| 1003 | 1006 | ObjectDefineProperty(Socket.prototype, '_queue', { | | 1007 | + __proto__: null, | 1004 | 1008 | get: deprecate(function() { | 1005 | 1009 | return this[kStateSymbol].queue; | 1006 | 1010 | }, 'Socket.prototype._queue is deprecated', 'DEP0112'), | @@ -1011,6 +1015,7 @@ ObjectDefineProperty(Socket.prototype, '_queue', { | 1011 | 1015 |
| 1012 | 1016 |
| 1013 | 1017 | ObjectDefineProperty(Socket.prototype, '_reuseAddr', { | | 1018 | + __proto__: null, | 1014 | 1019 | get: deprecate(function() { | 1015 | 1020 | return this[kStateSymbol].reuseAddr; | 1016 | 1021 | }, 'Socket.prototype._reuseAddr is deprecated', 'DEP0112'), | @@ -1033,6 +1038,7 @@ Socket.prototype._stopReceiving = deprecate(function() { | 1033 | 1038 | // Legacy alias on the C++ wrapper object. This is not public API, so we may | 1034 | 1039 | // want to runtime-deprecate it at some point. There's no hurry, though. | 1035 | 1040 | ObjectDefineProperty(UDP.prototype, 'owner', { | | 1041 | + __proto__: null, | 1036 | 1042 | get() { return this[owner_symbol]; }, | 1037 | 1043 | set(v) { return this[owner_symbol] = v; } | 1038 | 1044 | }); | |
Collapse file Copy file name to clipboardExpand all lines: lib/dns.js +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -198,7 +198,7 @@ function lookup(hostname, options, callback) { | 198 | 198 | } | 199 | 199 |
| 200 | 200 | ObjectDefineProperty(lookup, customPromisifyArgs, | 201 | | - { value: ['address', 'family'], enumerable: false }); | | 201 | + { __proto__: null, value: ['address', 'family'], enumerable: false }); | 202 | 202 |
| 203 | 203 |
| 204 | 204 | function onlookupservice(err, hostname, service) { | @@ -243,7 +243,7 @@ function lookupService(address, port, callback) { | 243 | 243 | } | 244 | 244 |
| 245 | 245 | ObjectDefineProperty(lookupService, customPromisifyArgs, | 246 | | - { value: ['hostname', 'service'], enumerable: false }); | | 246 | + { __proto__: null, value: ['hostname', 'service'], enumerable: false }); | 247 | 247 |
| 248 | 248 |
| 249 | 249 | function onresolve(err, result, ttls) { | @@ -288,7 +288,7 @@ function resolver(bindingName) { | 288 | 288 | }); | 289 | 289 | return req; | 290 | 290 | } | 291 | | - ObjectDefineProperty(query, 'name', { value: bindingName }); | | 291 | + ObjectDefineProperty(query, 'name', { __proto__: null, value: bindingName }); | 292 | 292 | return query; | 293 | 293 | } | 294 | 294 |
| @@ -381,6 +381,7 @@ bindDefaultResolver(module.exports, getDefaultResolver()); | 381 | 381 |
| 382 | 382 | ObjectDefineProperties(module.exports, { | 383 | 383 | promises: { | | 384 | + __proto__: null, | 384 | 385 | configurable: true, | 385 | 386 | enumerable: true, | 386 | 387 | get() { | |
|