Skip to content

Commit 9398365

Browse files
committed
Updated the private stream close method to only call isPaused if it exists i.e. >= Node 0.12
1 parent 54b3d51 commit 9398365

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/querystream.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,14 @@ function close(callback) {
182182
// to allow _doneFetching to be emitted if needed.
183183
self._closed = true;
184184

185-
if (!self.isPaused()) {
185+
// Node.js 0.10 didn't have an isPaused method that could be used to prevent
186+
// an unnecessary pause event from being emitted (added in 0.11.14). We'll
187+
// check for the existence of such a method and use it if possible, otherwise
188+
// we'll just call pause. This could be simplified a little when support for
189+
// Node.js 0.10 is dropped.
190+
if (typeof self.isPaused === 'function' && !self.isPaused()) {
191+
self.pause();
192+
} else {
186193
self.pause();
187194
}
188195

File renamed without changes.

0 commit comments

Comments
 (0)