Skip to content

Commit 3bd472e

Browse files
committed
Handle empty arrays
1 parent a066e5a commit 3bd472e

File tree

1 file changed

+5
-5
lines changed
  • lib/node_modules/@stdlib/streams/node/from-array/lib

1 file changed

+5
-5
lines changed

lib/node_modules/@stdlib/streams/node/from-array/lib/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ function read() {
5757
while ( FLG ) {
5858
err = null;
5959

60-
v = this._src[ this._idx ];
6160
this._i += 1;
61+
if ( this._i > this._src.length ) {
62+
debug( 'Finished iteration.' );
63+
return this.push( null );
64+
}
65+
v = this._src[ this._idx ];
6266
debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );
6367

6468
this._idx += this._stride;
@@ -83,10 +87,6 @@ function read() {
8387
} else {
8488
FLG = this.push( v );
8589
}
86-
if ( this._i === this._src.length ) {
87-
debug( 'Finished iteration.' );
88-
return this.push( null );
89-
}
9090
}
9191

9292
/* eslint-enable no-invalid-this */

0 commit comments

Comments
 (0)