File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 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 {
7676 async touchNext ( count = 1 ) {
7777 let idx = 0 ;
7878 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 ;
8182 }
83+ this . push ( await this . iterator . next ( ) ) ;
8284 }
8385 // Return the last cached {value, done} object to allow the calling
8486 // 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 {
4646 touchNext ( count = 1 ) {
4747 let idx = 0 ;
4848 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 ;
5152 }
53+ this . push ( this . iterator . next ( ) ) ;
5254 }
5355 // Return the last cached {value, done} object to allow the calling
5456 // code to decide if it needs to call touchNext again.
You can’t perform that action at this time.
0 commit comments