Skip to content

Commit 12a4069

Browse files
committed
Add callback to stopPoll
1 parent d5a8810 commit 12a4069

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ the kernel at all times to ensure continuous data flow. This is handled by the
219219
libusb event thread, so it continues even if the Node v8 thread is busy. The
220220
`data` and `error` events are emitted as transfers complete.
221221

222-
### .stopPoll()
222+
### .stopPoll(cb)
223223
Stop polling.
224224

225-
Further data may still be received. The `end` event is emitted once all transfers have completed or canceled.
225+
Further data may still be received. The `end` event is emitted and the callback
226+
is called once all transfers have completed or canceled.
226227

227228
### Event: data(data : Buffer)
228229
Emitted with data received by the polling transfers

usb.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,15 @@ Endpoint.prototype.startPoll = function(nTransfers, transferSize, callback){
247247
return transfers;
248248
}
249249

250-
Endpoint.prototype.stopPoll = function(){
250+
Endpoint.prototype.stopPoll = function(cb){
251251
if (!this.pollTransfers) {
252252
throw new Error('Polling is not active.');
253253
}
254254
for (var i=0; i<this.pollTransfers.length; i++){
255255
this.pollTransfers[i].cancel()
256256
}
257257
this.pollActive = false
258+
if (cb) this.once('end', cb);
258259
}
259260

260261
function InEndpoint(device, descriptor){

0 commit comments

Comments
 (0)