Skip to content

Commit 5565ef5

Browse files
authored
Use local reference for clearTimeout global
This ensures it is robust against stubbing in tests as is done with safeSetTimeout.
1 parent 342c89a commit 5565ef5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: lib/test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var nextTick = typeof setImmediate !== 'undefined'
1616
: process.nextTick
1717
;
1818
var safeSetTimeout = setTimeout;
19+
var safeClearTimeout = clearTimeout;
1920

2021
inherits(Test, EventEmitter);
2122

@@ -127,7 +128,7 @@ Test.prototype.timeoutAfter = function(ms) {
127128
self.end();
128129
}, ms);
129130
this.once('end', function() {
130-
clearTimeout(timeout);
131+
safeClearTimeout(timeout);
131132
});
132133
}
133134

0 commit comments

Comments
 (0)