File tree Expand file tree Collapse file tree 2 files changed +12
-18
lines changed
Expand file tree Collapse file tree 2 files changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -232,10 +232,13 @@ async function toArray(options) {
232232 return result ;
233233}
234234
235- async function * flatMap ( fn , options ) {
236- for await ( const val of this . map ( fn , options ) ) {
237- yield * val ;
238- }
235+ function flatMap ( fn , options ) {
236+ const values = this . map ( fn , options ) ;
237+ return async function * flatMap ( ) {
238+ for await ( const val of values ) {
239+ yield * val ;
240+ }
241+ } ( ) ;
239242}
240243
241244function toIntegerOrInfinity ( number ) {
Original file line number Diff line number Diff line change @@ -109,20 +109,11 @@ function oneTo5() {
109109
110110{
111111 // Error cases
112- assert . rejects ( async ( ) => {
113- // eslint-disable-next-line no-unused-vars
114- for await ( const unused of Readable . from ( [ 1 ] ) . flatMap ( 1 ) ) ;
115- } , / E R R _ I N V A L I D _ A R G _ T Y P E / ) . then ( common . mustCall ( ) ) ;
116- assert . rejects ( async ( ) => {
117- // eslint-disable-next-line no-unused-vars
118- for await ( const _ of Readable . from ( [ 1 ] ) . flatMap ( ( x ) => x , {
119- concurrency : 'Foo'
120- } ) ) ;
121- } , / E R R _ O U T _ O F _ R A N G E / ) . then ( common . mustCall ( ) ) ;
122- assert . rejects ( async ( ) => {
123- // eslint-disable-next-line no-unused-vars
124- for await ( const _ of Readable . from ( [ 1 ] ) . flatMap ( ( x ) => x , 1 ) ) ;
125- } , / E R R _ I N V A L I D _ A R G _ T Y P E / ) . then ( common . mustCall ( ) ) ;
112+ assert . throws ( ( ) => Readable . from ( [ 1 ] ) . flatMap ( 1 ) , / E R R _ I N V A L I D _ A R G _ T Y P E / ) ;
113+ assert . throws ( ( ) => Readable . from ( [ 1 ] ) . flatMap ( ( x ) => x , {
114+ concurrency : 'Foo'
115+ } ) , / E R R _ O U T _ O F _ R A N G E / ) ;
116+ assert . throws ( ( ) => Readable . from ( [ 1 ] ) . flatMap ( ( x ) => x , 1 ) , / E R R _ I N V A L I D _ A R G _ T Y P E / ) ;
126117}
127118{
128119 // Test result is a Readable
You can’t perform that action at this time.
0 commit comments