Skip to content
Prev Previous commit
Next Next commit
tls: avoid using forEach
  • Loading branch information
jasnell committed Mar 15, 2017
commit a2d8baad154f214af146a2f5827d357e3336e774
10 changes: 7 additions & 3 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,16 @@ var proxiedMethods = [
];

// Proxy HandleWrap, PipeWrap and TCPWrap methods
proxiedMethods.forEach(function(name) {
tls_wrap.TLSWrap.prototype[name] = function methodProxy(...args) {
function makeMethodProxy(name) {
return function methodProxy(...args) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why ...args is being used when we're just using it with .apply() which should handle arguments just fine.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way works for me really

Copy link
Copy Markdown
Contributor

@mscdex mscdex Mar 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote for changing to using arguments while we're in here.

if (this._parent[name])
return this._parent[name].apply(this._parent, args);
};
});
}
for (var n = 0; n < proxiedMethods.length; n++) {
tls_wrap.TLSWrap.prototype[proxiedMethods[n]] =
makeMethodProxy(proxiedMethods[n]);
}

tls_wrap.TLSWrap.prototype.close = function close(cb) {
let ssl;
Expand Down