Skip to content

Commit

Permalink
[Refactor] Test: skip binding for a non-function value
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 30, 2023
1 parent 26a75bb commit e244e64
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

Expand Down

0 comments on commit e244e64

Please sign in to comment.