@@ -14,7 +14,7 @@ async function tests() {
14
14
AsyncIteratorPrototype ) ;
15
15
}
16
16
17
- await ( async function ( ) {
17
+ {
18
18
const readable = new Readable ( { objectMode : true , read ( ) { } } ) ;
19
19
readable . push ( 0 ) ;
20
20
readable . push ( 1 ) ;
@@ -25,9 +25,9 @@ async function tests() {
25
25
for await ( const d of iter ) {
26
26
assert . strictEqual ( d , 1 ) ;
27
27
}
28
- } ) ( ) ;
28
+ }
29
29
30
- await ( async function ( ) {
30
+ {
31
31
console . log ( 'read without for..await' ) ;
32
32
const max = 5 ;
33
33
const readable = new Readable ( {
@@ -55,9 +55,9 @@ async function tests() {
55
55
56
56
const last = await iter . next ( ) ;
57
57
assert . strictEqual ( last . done , true ) ;
58
- } ) ( ) ;
58
+ }
59
59
60
- await ( async function ( ) {
60
+ {
61
61
console . log ( 'read without for..await deferred' ) ;
62
62
const readable = new Readable ( {
63
63
objectMode : true ,
@@ -95,9 +95,9 @@ async function tests() {
95
95
96
96
const last = await iter . next ( ) ;
97
97
assert . strictEqual ( last . done , true ) ;
98
- } ) ( ) ;
98
+ }
99
99
100
- await ( async function ( ) {
100
+ {
101
101
console . log ( 'read without for..await with errors' ) ;
102
102
const max = 3 ;
103
103
const readable = new Readable ( {
@@ -133,9 +133,9 @@ async function tests() {
133
133
} ) ;
134
134
135
135
readable . destroy ( new Error ( 'kaboom' ) ) ;
136
- } ) ( ) ;
136
+ }
137
137
138
- await ( async function ( ) {
138
+ {
139
139
console . log ( 'call next() after error' ) ;
140
140
const readable = new Readable ( {
141
141
read ( ) { }
@@ -145,9 +145,9 @@ async function tests() {
145
145
const err = new Error ( 'kaboom' ) ;
146
146
readable . destroy ( new Error ( 'kaboom' ) ) ;
147
147
await assert . rejects ( iterator . next . bind ( iterator ) , err ) ;
148
- } ) ( ) ;
148
+ }
149
149
150
- await ( async function ( ) {
150
+ {
151
151
console . log ( 'read object mode' ) ;
152
152
const max = 42 ;
153
153
let readed = 0 ;
@@ -168,9 +168,9 @@ async function tests() {
168
168
}
169
169
170
170
assert . strictEqual ( readed , received ) ;
171
- } ) ( ) ;
171
+ }
172
172
173
- await ( async function ( ) {
173
+ {
174
174
console . log ( 'destroy sync' ) ;
175
175
const readable = new Readable ( {
176
176
objectMode : true ,
@@ -187,9 +187,9 @@ async function tests() {
187
187
err = e ;
188
188
}
189
189
assert . strictEqual ( err . message , 'kaboom from read' ) ;
190
- } ) ( ) ;
190
+ }
191
191
192
- await ( async function ( ) {
192
+ {
193
193
console . log ( 'destroy async' ) ;
194
194
const readable = new Readable ( {
195
195
objectMode : true ,
@@ -219,9 +219,9 @@ async function tests() {
219
219
220
220
assert . strictEqual ( err . message , 'kaboom' ) ;
221
221
assert . strictEqual ( received , 1 ) ;
222
- } ) ( ) ;
222
+ }
223
223
224
- await ( async function ( ) {
224
+ {
225
225
console . log ( 'destroyed by throw' ) ;
226
226
const readable = new Readable ( {
227
227
objectMode : true ,
@@ -242,9 +242,9 @@ async function tests() {
242
242
243
243
assert . strictEqual ( err . message , 'kaboom' ) ;
244
244
assert . strictEqual ( readable . destroyed , true ) ;
245
- } ) ( ) ;
245
+ }
246
246
247
- await ( async function ( ) {
247
+ {
248
248
console . log ( 'destroyed sync after push' ) ;
249
249
const readable = new Readable ( {
250
250
objectMode : true ,
@@ -268,9 +268,9 @@ async function tests() {
268
268
269
269
assert . strictEqual ( err . message , 'kaboom' ) ;
270
270
assert . strictEqual ( received , 1 ) ;
271
- } ) ( ) ;
271
+ }
272
272
273
- await ( async function ( ) {
273
+ {
274
274
console . log ( 'push async' ) ;
275
275
const max = 42 ;
276
276
let readed = 0 ;
@@ -293,9 +293,9 @@ async function tests() {
293
293
}
294
294
295
295
assert . strictEqual ( readed , received ) ;
296
- } ) ( ) ;
296
+ }
297
297
298
- await ( async function ( ) {
298
+ {
299
299
console . log ( 'push binary async' ) ;
300
300
const max = 42 ;
301
301
let readed = 0 ;
@@ -323,9 +323,9 @@ async function tests() {
323
323
}
324
324
325
325
assert . strictEqual ( data , expected ) ;
326
- } ) ( ) ;
326
+ }
327
327
328
- await ( async function ( ) {
328
+ {
329
329
console . log ( '.next() on destroyed stream' ) ;
330
330
const readable = new Readable ( {
331
331
read ( ) {
@@ -337,9 +337,9 @@ async function tests() {
337
337
338
338
const { done } = await readable [ Symbol . asyncIterator ] ( ) . next ( ) ;
339
339
assert . strictEqual ( done , true ) ;
340
- } ) ( ) ;
340
+ }
341
341
342
- await ( async function ( ) {
342
+ {
343
343
console . log ( '.next() on pipelined stream' ) ;
344
344
const readable = new Readable ( {
345
345
read ( ) {
@@ -358,9 +358,9 @@ async function tests() {
358
358
} catch ( e ) {
359
359
assert . strictEqual ( e , err ) ;
360
360
}
361
- } ) ( ) ;
361
+ }
362
362
363
- await ( async ( ) => {
363
+ {
364
364
console . log ( 'iterating on an ended stream completes' ) ;
365
365
const r = new Readable ( {
366
366
objectMode : true ,
@@ -376,9 +376,9 @@ async function tests() {
376
376
// eslint-disable-next-line no-unused-vars
377
377
for await ( const b of r ) {
378
378
}
379
- } ) ( ) ;
379
+ }
380
380
381
- await ( async ( ) => {
381
+ {
382
382
console . log ( 'destroy mid-stream does not error' ) ;
383
383
const r = new Readable ( {
384
384
objectMode : true ,
@@ -392,9 +392,9 @@ async function tests() {
392
392
for await ( const a of r ) {
393
393
r . destroy ( null ) ;
394
394
}
395
- } ) ( ) ;
395
+ }
396
396
397
- await ( async ( ) => {
397
+ {
398
398
console . log ( 'all next promises must be resolved on end' ) ;
399
399
const r = new Readable ( {
400
400
objectMode : true ,
@@ -408,9 +408,9 @@ async function tests() {
408
408
r . push ( null ) ;
409
409
assert . deepStrictEqual ( await c , { done : true , value : undefined } ) ;
410
410
assert . deepStrictEqual ( await d , { done : true , value : undefined } ) ;
411
- } ) ( ) ;
411
+ }
412
412
413
- await ( async ( ) => {
413
+ {
414
414
console . log ( 'all next promises must be resolved on destroy' ) ;
415
415
const r = new Readable ( {
416
416
objectMode : true ,
@@ -424,9 +424,9 @@ async function tests() {
424
424
r . destroy ( ) ;
425
425
assert . deepStrictEqual ( await c , { done : true , value : undefined } ) ;
426
426
assert . deepStrictEqual ( await d , { done : true , value : undefined } ) ;
427
- } ) ( ) ;
427
+ }
428
428
429
- await ( async ( ) => {
429
+ {
430
430
console . log ( 'all next promises must be resolved on destroy with error' ) ;
431
431
const r = new Readable ( {
432
432
objectMode : true ,
@@ -457,7 +457,7 @@ async function tests() {
457
457
}
458
458
assert . strictEqual ( e , err ) ;
459
459
} ) ( ) ] ) ;
460
- } ) ( ) ;
460
+ }
461
461
}
462
462
463
463
// to avoid missing some tests if a promise does not resolve
0 commit comments