diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 2f146f3b9f1171..0f1bcb00b1c304 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -21,7 +21,13 @@ 'use strict'; -const { Object } = primordials; +const { + Object: { + setPrototypeOf: ObjectSetPrototypeOf, + keys: ObjectKeys, + values: ObjectValues + } +} = primordials; const net = require('net'); const EventEmitter = require('events'); @@ -124,8 +130,8 @@ function Agent(options) { // Don't emit keylog events unless there is a listener for them. this.on('newListener', maybeEnableKeylog); } -Object.setPrototypeOf(Agent.prototype, EventEmitter.prototype); -Object.setPrototypeOf(Agent, EventEmitter); +ObjectSetPrototypeOf(Agent.prototype, EventEmitter.prototype); +ObjectSetPrototypeOf(Agent, EventEmitter); function maybeEnableKeylog(eventName) { if (eventName === 'keylog') { @@ -136,7 +142,7 @@ function maybeEnableKeylog(eventName) { agent.emit('keylog', keylog, this); }; // Existing sockets will start listening on keylog now. - const sockets = Object.values(this.sockets); + const sockets = ObjectValues(this.sockets); for (let i = 0; i < sockets.length; i++) { sockets[i].on('keylog', this[kOnKeylog]); } @@ -371,7 +377,7 @@ Agent.prototype.destroy = function destroy() { const sets = [this.freeSockets, this.sockets]; for (let s = 0; s < sets.length; s++) { const set = sets[s]; - const keys = Object.keys(set); + const keys = ObjectKeys(set); for (let v = 0; v < keys.length; v++) { const setName = set[keys[v]]; for (let n = 0; n < setName.length; n++) {