Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
seguri opened this issue Oct 15, 2024 · 0 comments
Open

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

seguri opened this issue Oct 15, 2024 · 0 comments

Comments

@seguri
Copy link

seguri commented Oct 15, 2024

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")));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant