Skip to content

[QUESTION] Why aren't these two statements equivalent? #1033

@seguri

Description

@seguri

Hi,
I'm new to the project and the Stream API. After spending too much time getting the first block below working, I was asking myself why it isn't equivalent to the second one. Could you kindly explain me what I'm doing wrong there?
Thanks!

Working:

const enhance = (filename) => {
  const inPath = path.join(__dirname, filename);
  const outStream = fs.createWriteStream(inPath.replace(".csv", ".transformed.csv"));
  parseFile(inPath, { headers: true })
    .transform(myTransformerFunction)
    .pipe(format({ headers: true }))
    .pipe(outStream);
};

Not working:

const enhance = (filename) => {
  const inPath = path.join(__dirname, filename);
  parseFile(inPath, { headers: true })
    .transform(myTransformerFunction)
    .pipe(writeToPath(inPath.replace(".csv", ".transformed.csv")));
};

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