From 646ee559df99f2f22c3eb0cf05684ed9931f28c6 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sat, 25 Feb 2017 22:41:45 -0800 Subject: [PATCH] tls: avoid using forEach PR-URL: https://github.com/nodejs/node/pull/11582 Reviewed-By: Matteo Collina Reviewed-By: Colin Ihrig --- lib/_tls_wrap.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 06b555a1254cbe..4ad79cf7a28d15 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -300,12 +300,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) { 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;