File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -76,9 +76,11 @@ export default class CachedAsyncIterable extends CachedIterable {
76
76
async touchNext ( count = 1 ) {
77
77
let idx = 0 ;
78
78
while ( idx ++ < count ) {
79
- if ( this . length === 0 || this [ this . length - 1 ] . done === false ) {
80
- this . push ( await this . iterator . next ( ) ) ;
79
+ const last = this [ this . length - 1 ] ;
80
+ if ( last && last . done ) {
81
+ break ;
81
82
}
83
+ this . push ( await this . iterator . next ( ) ) ;
82
84
}
83
85
// Return the last cached {value, done} object to allow the calling
84
86
// code to decide if it needs to call touchNext again.
Original file line number Diff line number Diff line change @@ -46,9 +46,11 @@ export default class CachedSyncIterable extends CachedIterable {
46
46
touchNext ( count = 1 ) {
47
47
let idx = 0 ;
48
48
while ( idx ++ < count ) {
49
- if ( this . length === 0 || this [ this . length - 1 ] . done === false ) {
50
- this . push ( this . iterator . next ( ) ) ;
49
+ const last = this [ this . length - 1 ] ;
50
+ if ( last && last . done ) {
51
+ break ;
51
52
}
53
+ this . push ( this . iterator . next ( ) ) ;
52
54
}
53
55
// Return the last cached {value, done} object to allow the calling
54
56
// code to decide if it needs to call touchNext again.
You can’t perform that action at this time.
0 commit comments