ability to provide "RedableFunction" as a StreamItem for input
To create a chain with input as a readable stream, the first element of the constructor's streamItem[] can be a readable stream. However, it would be great to have the ability to provide a ReadableFunction just like we allows a TransformFunction.
ReadableFunction then essentially returns the readable stream.
Use case: this is helpful to work with readable streams where an async operation is involved e.g. pg database.
Expectation: The following should work
new Chain([
async() => {
let client = new pg.client(...)
await client.connect()
return client.query(new QueryStream(...)) // a Promise<ReadableStream>
},
x => {console.log(x)}
]
Am I correct in assuming that you want to have a function that returns a stream, which should feed the rest of the pipe?
If that's the correct assumption, why not use something like that:
async function abc () { /* ... */ return stream; }
const pipeline = new Chain([ /* ... */ ]);
(await abc()).pipe(pipeline);
Whatever chain produces is just a regular stream, which can be used normally.
Closing for inactivity.