Skip to content

How to combine streams and not lose data #2037

@ORESoftware

Description

@ORESoftware

I have this question on SO:

https://stackoverflow.com/questions/56945909/combine-fs-createreadstream-with-process-stdin-stream

Basically I am continually writing to a file to keep track of old data.
At some point, I want to read the data from the file and then start reading the new data from stdin. I don't want to duplicate data nor do I want to lose data.

Is there some reliable way to do this?

process.stdin.resume().pipe(fs.createWriteStream('file'));

{
  // much later on

  const sws = new SomeWriteStream({end:false});

  fs.createReadStream('file').pipe(sws).once('end', () => {
    process.stdin.pipe(sws);
  });

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions