From e244e64eab7529c4e0d2391b989152b84229939e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 30 Jun 2023 15:01:27 -0500 Subject: [PATCH] [Refactor] `Test`: skip binding for a non-function value --- lib/test.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/test.js b/lib/test.js index f6a0e6b2..f4013bc1 100644 --- a/lib/test.js +++ b/lib/test.js @@ -88,15 +88,16 @@ function Test(name_, opts_, cb_) { this._objectPrintDepth = 5; } - for (var prop in this) { - this[prop] = (function bind(self, val) { - if (typeof val === 'function') { + var self = this; + for (var prop in self) { + if (typeof self[prop] === 'function') { + self[prop] = (function bind(propName) { + var val = self[propName]; return function bound() { return val.apply(self, arguments); }; - } - return val; - }(this, this[prop])); + }(prop)); + } } }