Given a stream Readable(which may be process.stdineither a stream of files), is it possible / practical to use pipe()for a user stream Writablethat will fill a child Writableto a certain size; then close this child thread; open a new stream Writableand continue?
(The context is to load most of the data from the pipeline into the CDN, dividing it into blocks of a reasonable size as they appear, without having to write the data to disk first.)
I tried to create Writableone that handles opening and closing a child stream in a function _write, but the problem arises when the incoming fragment is too large to fit into an existing child stream: it has to write a piece of the piece to the old stream; create a new thread; and then wait for the event openin the new thread to complete the call _write.
Another thought that I had was to create an additional stream, Duplexeither Transformto buffer the channel and ensure that the piece included in Writableis definitely equal to or less than the amount that the existing accept child stream can have to give Writabletime to change the child stream.
Alternatively, is this all superfluous, and is it much easier to complete the initial task there?
source
share