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

Can you help me see why 'line' events are not being emitted? #16

Open
brycepj opened this issue Jun 15, 2017 · 0 comments
Open

Can you help me see why 'line' events are not being emitted? #16

brycepj opened this issue Jun 15, 2017 · 0 comments

Comments

@brycepj
Copy link

brycepj commented Jun 15, 2017

Hi, I'm somewhat new to streams, so I assume I'm missing something basic here.

Assuming filePath is defined and associated with a large file, why would end events be emitted, but line events never are? mutatedBuffer isn't really important here, just part of the context. Thanks in advance.

function writeFileLineByLine(filePath) {
  const mutatedBuffer = new MutatedFileBuffer(filePath);

  const lineReader = new LineByLineReader(filePath);

  lineReader.on('line', (line) => {
    // never called
    const mutatedLine = `${line} plus appended`;
    mutatedBuffer.push(mutatedLine);
  });

  lineReader.on('error', (err) => {
    // never called
    console.error(err);
  });

  lineReader.on('end', () => {
    // called
    mutatedBuffer.store();
  });

  return lineReader;
}
@brycepj brycepj closed this as completed Jun 15, 2017
@brycepj brycepj reopened this Jun 15, 2017
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