@@ -114,7 +114,7 @@ Cursor.prototype._fetch = function() {
114
114
var self = this ;
115
115
this . _fetching = true ;
116
116
117
- var p = new Promise ( function ( resolve , reject ) {
117
+ return new Promise ( function ( resolve , reject ) {
118
118
self . connection . _continue ( self . token , resolve , reject ) ;
119
119
} ) . then ( function ( response ) {
120
120
self . _push ( response ) ;
@@ -124,6 +124,7 @@ Cursor.prototype._fetch = function() {
124
124
self . _canFetch = false ;
125
125
self . _pushError ( error ) ;
126
126
} )
127
+
127
128
}
128
129
129
130
Cursor . prototype . _push = function ( data ) {
@@ -142,7 +143,7 @@ Cursor.prototype._push = function(data) {
142
143
// Try to solve as many pending promises as possible
143
144
Cursor . prototype . _flush = function ( ) {
144
145
while ( ( this . _pendingPromises . length > 0 ) && ( ( this . _data . length > 0 ) || ( ( this . _fetching === false ) && ( this . _canFetch === false ) ) ) ) {
145
- var fullfiller = this . _pendingPromises . shift ( ) ;
146
+ var fullfiller = this . _pendingPromises . shift ( ) ;
146
147
var resolve = fullfiller . resolve ;
147
148
var reject = fullfiller . reject ;
148
149
@@ -268,7 +269,7 @@ Cursor.prototype._each = function(callback, onFinish) {
268
269
}
269
270
270
271
self . _next ( ) . then ( resolve ) . error ( function ( error ) {
271
- // We can silence error when the cursor is closed as this
272
+ // We can silence error when the cursor is closed as this
272
273
if ( ( error . message !== 'You cannot retrieve data from a cursor that is closed.' ) &&
273
274
( error . message . match ( / Y o u c a n n o t c a l l ` n e x t ` o n a c l o s e d / ) === null ) ) {
274
275
reject ( error ) ;
@@ -291,26 +292,26 @@ Cursor.prototype._eachAsyncInternal = function(callback, finalResolve, finalReje
291
292
292
293
var nextCb = function ( ) {
293
294
self . _stackSize ++ ;
294
- self . _next ( ) . then ( function ( row ) {
295
+ return self . _next ( ) . then ( function ( row ) {
295
296
if ( self . _stackSize <= MAX_CALL_STACK ) {
296
297
if ( callback . length <= 1 ) {
297
- Promise . resolve ( callback ( row ) ) . then ( nextCb )
298
+ return Promise . resolve ( callback ( row ) ) . then ( nextCb )
298
299
}
299
300
else {
300
- new Promise ( function ( resolve , reject ) {
301
+ return new Promise ( function ( resolve , reject ) {
301
302
return callback ( row , resolve )
302
303
} ) . then ( nextCb ) ;
303
304
}
304
305
}
305
306
else {
306
- new Promise ( function ( resolve , reject ) {
307
+ return new Promise ( function ( resolve , reject ) {
307
308
setTimeout ( function ( ) {
308
309
self . _stackSize = 0 ;
309
310
if ( callback . length <= 1 ) {
310
- Promise . resolve ( callback ( row ) ) . then ( resolve ) . catch ( reject ) ;
311
+ return Promise . resolve ( callback ( row ) ) . then ( resolve ) . catch ( reject ) ;
311
312
}
312
313
else {
313
- new Promise ( function ( resolve , reject ) {
314
+ return new Promise ( function ( resolve , reject ) {
314
315
return callback ( row , resolve )
315
316
} ) . then ( resolve ) . catch ( reject ) ;
316
317
}
0 commit comments