File tree 1 file changed +27
-9
lines changed
1 file changed +27
-9
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- async function * asyncIterator ( ) {
4
- while ( true ) {
5
- const value = await this . next ( ) ;
6
- if ( ! value ) {
7
- await this . close ( ) ;
8
- return ;
9
- }
3
+ // async function* asyncIterator() {
4
+ // while (true) {
5
+ // const value = await this.next();
6
+ // if (!value) {
7
+ // await this.close();
8
+ // return;
9
+ // }
10
+
11
+ // yield value;
12
+ // }
13
+ // }
10
14
11
- yield value ;
12
- }
15
+ // TODO: change this to the async generator function above
16
+ function asyncIterator ( ) {
17
+ const cursor = this ;
18
+
19
+ return {
20
+ next : function ( ) {
21
+ return Promise . resolve ( )
22
+ . then ( ( ) => cursor . next ( ) )
23
+ . then ( value => {
24
+ if ( ! value ) {
25
+ return cursor . close ( ) . then ( ( ) => ( { value, done : true } ) ) ;
26
+ }
27
+ return { value, done : false } ;
28
+ } ) ;
29
+ }
30
+ } ;
13
31
}
14
32
15
33
exports . asyncIterator = asyncIterator ;
You can’t perform that action at this time.
0 commit comments