Skip to content

Commit 8c9e8be

Browse files
committed
reverts to using once instead of on
1 parent e316d1d commit 8c9e8be

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/stream-to-async-iterator.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,15 @@ export default class StreamAsyncToIterator {
165165
eventListener = () => {
166166
this._state = states.readable;
167167
this._rejections.delete(reject);
168+
169+
// we set this to null to info the clean up not to do anything
170+
eventListener = null;
168171
resolve();
169172
};
170173

171174
//on is used here instead of once, because
172175
//the listener is remove afterwards anyways.
173-
this._stream.on('readable', eventListener);
176+
this._stream.once('readable', eventListener);
174177
this._rejections.add(reject);
175178
});
176179

@@ -194,10 +197,12 @@ export default class StreamAsyncToIterator {
194197
eventListener = () => {
195198
this._state = states.ended;
196199
this._rejections.delete(reject);
200+
201+
eventListener = null
197202
resolve();
198203
};
199204

200-
this._stream.on('end', eventListener);
205+
this._stream.once('end', eventListener);
201206
this._rejections.add(reject);
202207
});
203208

0 commit comments

Comments
 (0)