Skip to content

Commit 0646eda

Browse files
committedNov 25, 2019
lib: flatten access to primordials
Store all primordials as properties of the primordials object. Static functions are prefixed by the constructor's name and prototype methods are prefixed by the constructor's name followed by "Prototype". For example: primordials.Object.keys becomes primordials.ObjectKeys. PR-URL: nodejs#30610 Refs: nodejs#29766 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 35c6e0c commit 0646eda

File tree

117 files changed

+1317
-943
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1317
-943
lines changed
 

‎lib/_http_agent.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
'use strict';
2323

2424
const {
25-
Object: {
26-
setPrototypeOf: ObjectSetPrototypeOf,
27-
keys: ObjectKeys,
28-
values: ObjectValues
29-
}
25+
ObjectKeys,
26+
ObjectSetPrototypeOf,
27+
ObjectValues,
3028
} = primordials;
3129

3230
const net = require('net');

‎lib/_http_client.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121

2222
'use strict';
2323

24-
const { Object } = primordials;
24+
const {
25+
ObjectAssign,
26+
ObjectKeys,
27+
ObjectSetPrototypeOf,
28+
} = primordials;
2529

2630
const net = require('net');
2731
const url = require('url');
@@ -107,7 +111,7 @@ function ClientRequest(input, options, cb) {
107111
cb = options;
108112
options = input || {};
109113
} else {
110-
options = Object.assign(input || {}, options);
114+
options = ObjectAssign(input || {}, options);
111115
}
112116

113117
let agent = options.agent;
@@ -216,7 +220,7 @@ function ClientRequest(input, options, cb) {
216220
const headersArray = Array.isArray(options.headers);
217221
if (!headersArray) {
218222
if (options.headers) {
219-
const keys = Object.keys(options.headers);
223+
const keys = ObjectKeys(options.headers);
220224
for (let i = 0; i < keys.length; i++) {
221225
const key = keys[i];
222226
this.setHeader(key, options.headers[key]);
@@ -295,8 +299,8 @@ function ClientRequest(input, options, cb) {
295299

296300
this._deferToConnect(null, null, () => this._flush());
297301
}
298-
Object.setPrototypeOf(ClientRequest.prototype, OutgoingMessage.prototype);
299-
Object.setPrototypeOf(ClientRequest, OutgoingMessage);
302+
ObjectSetPrototypeOf(ClientRequest.prototype, OutgoingMessage.prototype);
303+
ObjectSetPrototypeOf(ClientRequest, OutgoingMessage);
300304

301305
ClientRequest.prototype._finish = function _finish() {
302306
DTRACE_HTTP_CLIENT_REQUEST(this, this.socket);

0 commit comments

Comments
 (0)
Please sign in to comment.