File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
lib/node_modules/@stdlib/iter/none Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -38,23 +38,27 @@ function createIterator( arr ) {
3838
3939 it = { } ;
4040 it . next = next ;
41+ it . reset = reset ;
4142
4243 return it ;
4344
4445 function next ( ) {
4546 i += 1 ;
46- if ( i < len - 1 ) {
47+ if ( i < len ) {
4748 return {
4849 'value' : arr [ i ] ,
4950 'done' : false
5051 } ;
5152 }
5253 i = - 1 ; // reset index
5354 return {
54- 'value' : arr [ len - 1 ] ,
5555 'done' : true
5656 } ;
5757 }
58+
59+ function reset ( ) {
60+ i = - 1 ;
61+ }
5862}
5963
6064
@@ -73,6 +77,7 @@ bench( pkg, function benchmark( b ) {
7377 if ( ! isBoolean ( bool ) ) {
7478 b . fail ( 'should return a boolean' ) ;
7579 }
80+ arr . reset ( ) ;
7681 }
7782 b . toc ( ) ;
7883 if ( ! isBoolean ( bool ) ) {
@@ -104,6 +109,7 @@ bench( pkg+'::loop', function benchmark( b ) {
104109 if ( ! isBoolean ( bool ) ) {
105110 b . fail ( 'should be a boolean' ) ;
106111 }
112+ arr . reset ( ) ;
107113 }
108114 b . toc ( ) ;
109115 if ( ! isBoolean ( bool ) ) {
Original file line number Diff line number Diff line change @@ -47,14 +47,13 @@ function iterNone( iterator ) {
4747 }
4848 while ( true ) {
4949 v = iterator . next ( ) ;
50+ if ( v . done ) {
51+ return true ;
52+ }
5053 if ( v . value ) {
5154 return false ;
5255 }
53- if ( v . done ) {
54- break ;
55- }
5656 }
57- return true ;
5857}
5958
6059
You can’t perform that action at this time.
0 commit comments