File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ declare module "stream" {
1818 }
1919
2020 class Readable extends Stream implements NodeJS . ReadableStream {
21+ static from ( iterable : Iterable < any > | AsyncIterable < any > , opts ?: ReadableOptions ) : NodeJS . ReadableStream ;
2122 readable : boolean ;
2223 readonly readableHighWaterMark : number ;
2324 readonly readableLength : number ;
Original file line number Diff line number Diff line change @@ -192,3 +192,26 @@ function stream_readable_pipe_test() {
192192 z . close ( ) ;
193193 rs . close ( ) ;
194194}
195+
196+ async function readable_from ( ) {
197+
198+ const list = [ 1 , 2 , 3 ] ;
199+ const listPromise = list . map ( async n => await n ) ;
200+
201+ const readableSync = Readable . from ( list ) ;
202+ const readableAsync = Readable . from ( listPromise ) ;
203+
204+ let i = 0 ;
205+
206+ for await ( const n of readableSync ) {
207+ assert ( n === list [ i ++ ] ) ;
208+ }
209+
210+ i = 0 ;
211+
212+ for await ( const n of readableAsync ) {
213+ assert ( n === list [ i ++ ] ) ;
214+ }
215+
216+ }
217+
You can’t perform that action at this time.
0 commit comments